Minor changes to avoid bugs in some compilers.

This commit is contained in:
Davis King 2018-11-20 15:36:07 -05:00
parent 9ff911696c
commit 3e9d361f89
9 changed files with 24 additions and 24 deletions

View File

@ -122,7 +122,7 @@ std::vector<double> normalized_predict_vec (
{
std::vector<double> out;
out.reserve(samps.size());
for (auto& x : samps)
for (const auto& x : samps)
out.push_back(normalized_predict(df,x));
return out;
}

View File

@ -64,10 +64,10 @@ public:
throw dlib::error("The array of images and the array of array of locations must be of the same size");
int total_chips = 0;
for (auto& faces : batch_faces)
for (const auto& faces : batch_faces)
{
total_chips += faces.size();
for (auto& f : faces)
for (const auto& f : faces)
{
if (f.num_parts() != 68 && f.num_parts() != 5)
throw dlib::error("The full_object_detection must use the iBUG 300W 68 point face landmark style or dlib's 5 point style.");
@ -82,7 +82,7 @@ public:
auto& img = batch_imgs[i];
std::vector<chip_details> dets;
for (auto& f : faces)
for (const auto& f : faces)
dets.push_back(get_face_chip_details(f, 150, 0.25));
dlib::array<matrix<rgb_pixel>> this_img_face_chips;
extract_image_chips(img, dets, this_img_face_chips);
@ -214,12 +214,12 @@ void save_face_chips (
int num_faces = faces.size();
std::vector<chip_details> dets;
for (auto& f : faces)
for (const auto& f : faces)
dets.push_back(get_face_chip_details(f, size, padding));
dlib::array<matrix<rgb_pixel>> face_chips;
extract_image_chips(numpy_image<rgb_pixel>(img), dets, face_chips);
int i=0;
for (auto& chip : face_chips)
for (const auto& chip : face_chips)
{
i++;
if(num_faces > 1)

View File

@ -203,7 +203,7 @@ std::shared_ptr<global_function_search> py_global_function_search1 (
)
{
std::vector<function_spec> tmp;
for (auto i : functions)
for (const auto& i : functions)
tmp.emplace_back(i.cast<function_spec>());
return std::make_shared<global_function_search>(tmp);
@ -216,14 +216,14 @@ std::shared_ptr<global_function_search> py_global_function_search2 (
)
{
std::vector<function_spec> specs;
for (auto i : functions)
for (const auto& i : functions)
specs.emplace_back(i.cast<function_spec>());
std::vector<std::vector<function_evaluation>> func_evals;
for (auto i : initial_function_evals)
for (const auto& i : initial_function_evals)
{
std::vector<function_evaluation> evals;
for (auto j : i)
for (const auto& j : i)
{
evals.emplace_back(j.cast<function_evaluation>());
}
@ -410,12 +410,12 @@ simply a struct that records x and the scalar value F(x). )RAW")
std::vector<std::vector<function_evaluation>> function_evals;
self.get_function_evaluations(specs,function_evals);
py::list py_specs, py_func_evals;
for (auto& s : specs)
for (const auto& s : specs)
py_specs.append(s);
for (auto& i : function_evals)
for (const auto& i : function_evals)
{
py::list tmp;
for (auto& j : i)
for (const auto& j : i)
tmp.append(j);
py_func_evals.append(tmp);
}

View File

@ -97,7 +97,7 @@ void add_overlay_pylist (
)
{
std::vector<rectangle> rects;
for (auto& obj : objs)
for (const auto& obj : objs)
{
try { rects.push_back(obj.cast<rectangle>()); continue; } catch(py::cast_error&) { }
try { rects.push_back(obj.cast<drectangle>()); continue; } catch(py::cast_error&) { }

View File

@ -65,7 +65,7 @@ std::vector<point> py_remove_incoherent_edge_pixels (
DLIB_CASSERT(num_rows(horz_gradient) == num_rows(vert_gradient));
DLIB_CASSERT(num_columns(horz_gradient) == num_columns(vert_gradient));
DLIB_CASSERT(angle_threshold >= 0);
for (auto& p : line)
for (const auto& p : line)
DLIB_CASSERT(get_rect(horz_gradient).contains(p), "All line points must be inside the given images.");
return remove_incoherent_edge_pixels(line, horz_gradient, vert_gradient, angle_threshold);
@ -152,7 +152,7 @@ py::list py_extract_image_chips (
dlib::array<numpy_image<T>> out;
extract_image_chips(img, python_list_to_vector<chip_details>(chip_locations), out);
py::list ret;
for (auto& i : out)
for (const auto& i : out)
ret.append(i);
return ret;
}

View File

@ -511,7 +511,7 @@ py::list py_extract_image_chips (
dlib::array<numpy_image<T>> out;
extract_image_chips(img, python_list_to_vector<chip_details>(chip_locations), out);
py::list ret;
for (auto& i : out)
for (const auto& i : out)
ret.append(i);
return ret;
}

View File

@ -97,7 +97,7 @@ dataset py_load_image_dataset_metadata(
std::shared_ptr<std::map<std::string,point>> map_from_object(py::dict obj)
{
auto ret = std::make_shared<std::map<std::string,point>>();
for (auto& v : obj)
for (const auto& v : obj)
{
(*ret)[v.first.cast<std::string>()] = v.second.cast<point>();
}
@ -121,7 +121,7 @@ image_dataset_metadata::dataset py_make_bounding_box_regression_training_data (
// otherwise, detections should be a list of std::vectors.
py::list dets(detections);
std::vector<std::vector<rectangle>> temp;
for (auto& d : dets)
for (const auto& d : dets)
temp.emplace_back(d.cast<const std::vector<rectangle>&>());
return make_bounding_box_regression_training_data(truth, temp);
}
@ -174,7 +174,7 @@ void bind_image_dataset_metadata(py::module &m_)
auto partsstr = [](const std::map<std::string,point>& item) {
std::ostringstream sout;
sout << "{";
for (auto& v : item)
for (const auto& v : item)
sout << "'" << v.first << "': " << v.second << ", ";
sout << "}";
return sout.str();
@ -182,7 +182,7 @@ void bind_image_dataset_metadata(py::module &m_)
auto partsrepr = [](const std::map<std::string,point>& item) {
std::ostringstream sout;
sout << "dlib.image_dataset_metadata.parts({\n";
for (auto& v : item)
for (const auto& v : item)
sout << "'" << v.first << "': dlib.point" << v.second << ",\n";
sout << "})";
return sout.str();

View File

@ -97,12 +97,12 @@ py::list get_face_chips (
py::list chips_list;
std::vector<chip_details> dets;
for (auto& f : faces)
for (const auto& f : faces)
dets.push_back(get_face_chip_details(f, size, padding));
dlib::array<numpy_image<rgb_pixel>> face_chips;
extract_image_chips(img, dets, face_chips);
for (auto& chip : face_chips)
for (const auto& chip : face_chips)
{
// Append image to chips list
chips_list.append(chip);

View File

@ -72,7 +72,7 @@ std::shared_ptr<full_object_detection> full_obj_det_init(const rectangle& rect,
{
const unsigned long num_parts = py::len(pyparts);
std::vector<point> parts;
for (auto& item : pyparts)
for (const auto& item : pyparts)
parts.push_back(item.cast<point>());
return std::make_shared<full_object_detection>(rect, parts);