Commit 3e9d361f authored by Davis King's avatar Davis King

Minor changes to avoid bugs in some compilers.

parent 9ff91169
...@@ -122,7 +122,7 @@ std::vector<double> normalized_predict_vec ( ...@@ -122,7 +122,7 @@ std::vector<double> normalized_predict_vec (
{ {
std::vector<double> out; std::vector<double> out;
out.reserve(samps.size()); out.reserve(samps.size());
for (auto& x : samps) for (const auto& x : samps)
out.push_back(normalized_predict(df,x)); out.push_back(normalized_predict(df,x));
return out; return out;
} }
......
...@@ -64,10 +64,10 @@ public: ...@@ -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"); throw dlib::error("The array of images and the array of array of locations must be of the same size");
int total_chips = 0; int total_chips = 0;
for (auto& faces : batch_faces) for (const auto& faces : batch_faces)
{ {
total_chips += faces.size(); total_chips += faces.size();
for (auto& f : faces) for (const auto& f : faces)
{ {
if (f.num_parts() != 68 && f.num_parts() != 5) 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."); 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: ...@@ -82,7 +82,7 @@ public:
auto& img = batch_imgs[i]; auto& img = batch_imgs[i];
std::vector<chip_details> dets; 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)); dets.push_back(get_face_chip_details(f, 150, 0.25));
dlib::array<matrix<rgb_pixel>> this_img_face_chips; dlib::array<matrix<rgb_pixel>> this_img_face_chips;
extract_image_chips(img, dets, this_img_face_chips); extract_image_chips(img, dets, this_img_face_chips);
...@@ -214,12 +214,12 @@ void save_face_chips ( ...@@ -214,12 +214,12 @@ void save_face_chips (
int num_faces = faces.size(); int num_faces = faces.size();
std::vector<chip_details> dets; std::vector<chip_details> dets;
for (auto& f : faces) for (const auto& f : faces)
dets.push_back(get_face_chip_details(f, size, padding)); dets.push_back(get_face_chip_details(f, size, padding));
dlib::array<matrix<rgb_pixel>> face_chips; dlib::array<matrix<rgb_pixel>> face_chips;
extract_image_chips(numpy_image<rgb_pixel>(img), dets, face_chips); extract_image_chips(numpy_image<rgb_pixel>(img), dets, face_chips);
int i=0; int i=0;
for (auto& chip : face_chips) for (const auto& chip : face_chips)
{ {
i++; i++;
if(num_faces > 1) if(num_faces > 1)
......
...@@ -203,7 +203,7 @@ std::shared_ptr<global_function_search> py_global_function_search1 ( ...@@ -203,7 +203,7 @@ std::shared_ptr<global_function_search> py_global_function_search1 (
) )
{ {
std::vector<function_spec> tmp; std::vector<function_spec> tmp;
for (auto i : functions) for (const auto& i : functions)
tmp.emplace_back(i.cast<function_spec>()); tmp.emplace_back(i.cast<function_spec>());
return std::make_shared<global_function_search>(tmp); return std::make_shared<global_function_search>(tmp);
...@@ -216,14 +216,14 @@ std::shared_ptr<global_function_search> py_global_function_search2 ( ...@@ -216,14 +216,14 @@ std::shared_ptr<global_function_search> py_global_function_search2 (
) )
{ {
std::vector<function_spec> specs; std::vector<function_spec> specs;
for (auto i : functions) for (const auto& i : functions)
specs.emplace_back(i.cast<function_spec>()); specs.emplace_back(i.cast<function_spec>());
std::vector<std::vector<function_evaluation>> func_evals; 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; std::vector<function_evaluation> evals;
for (auto j : i) for (const auto& j : i)
{ {
evals.emplace_back(j.cast<function_evaluation>()); evals.emplace_back(j.cast<function_evaluation>());
} }
...@@ -410,12 +410,12 @@ simply a struct that records x and the scalar value F(x). )RAW") ...@@ -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; std::vector<std::vector<function_evaluation>> function_evals;
self.get_function_evaluations(specs,function_evals); self.get_function_evaluations(specs,function_evals);
py::list py_specs, py_func_evals; py::list py_specs, py_func_evals;
for (auto& s : specs) for (const auto& s : specs)
py_specs.append(s); py_specs.append(s);
for (auto& i : function_evals) for (const auto& i : function_evals)
{ {
py::list tmp; py::list tmp;
for (auto& j : i) for (const auto& j : i)
tmp.append(j); tmp.append(j);
py_func_evals.append(tmp); py_func_evals.append(tmp);
} }
......
...@@ -97,7 +97,7 @@ void add_overlay_pylist ( ...@@ -97,7 +97,7 @@ void add_overlay_pylist (
) )
{ {
std::vector<rectangle> rects; 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<rectangle>()); continue; } catch(py::cast_error&) { }
try { rects.push_back(obj.cast<drectangle>()); continue; } catch(py::cast_error&) { } try { rects.push_back(obj.cast<drectangle>()); continue; } catch(py::cast_error&) { }
......
...@@ -65,7 +65,7 @@ std::vector<point> py_remove_incoherent_edge_pixels ( ...@@ -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_rows(horz_gradient) == num_rows(vert_gradient));
DLIB_CASSERT(num_columns(horz_gradient) == num_columns(vert_gradient)); DLIB_CASSERT(num_columns(horz_gradient) == num_columns(vert_gradient));
DLIB_CASSERT(angle_threshold >= 0); 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."); 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); return remove_incoherent_edge_pixels(line, horz_gradient, vert_gradient, angle_threshold);
...@@ -152,7 +152,7 @@ py::list py_extract_image_chips ( ...@@ -152,7 +152,7 @@ py::list py_extract_image_chips (
dlib::array<numpy_image<T>> out; dlib::array<numpy_image<T>> out;
extract_image_chips(img, python_list_to_vector<chip_details>(chip_locations), out); extract_image_chips(img, python_list_to_vector<chip_details>(chip_locations), out);
py::list ret; py::list ret;
for (auto& i : out) for (const auto& i : out)
ret.append(i); ret.append(i);
return ret; return ret;
} }
......
...@@ -511,7 +511,7 @@ py::list py_extract_image_chips ( ...@@ -511,7 +511,7 @@ py::list py_extract_image_chips (
dlib::array<numpy_image<T>> out; dlib::array<numpy_image<T>> out;
extract_image_chips(img, python_list_to_vector<chip_details>(chip_locations), out); extract_image_chips(img, python_list_to_vector<chip_details>(chip_locations), out);
py::list ret; py::list ret;
for (auto& i : out) for (const auto& i : out)
ret.append(i); ret.append(i);
return ret; return ret;
} }
......
...@@ -97,7 +97,7 @@ dataset py_load_image_dataset_metadata( ...@@ -97,7 +97,7 @@ dataset py_load_image_dataset_metadata(
std::shared_ptr<std::map<std::string,point>> map_from_object(py::dict obj) std::shared_ptr<std::map<std::string,point>> map_from_object(py::dict obj)
{ {
auto ret = std::make_shared<std::map<std::string,point>>(); 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>(); (*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 ( ...@@ -121,7 +121,7 @@ image_dataset_metadata::dataset py_make_bounding_box_regression_training_data (
// otherwise, detections should be a list of std::vectors. // otherwise, detections should be a list of std::vectors.
py::list dets(detections); py::list dets(detections);
std::vector<std::vector<rectangle>> temp; std::vector<std::vector<rectangle>> temp;
for (auto& d : dets) for (const auto& d : dets)
temp.emplace_back(d.cast<const std::vector<rectangle>&>()); temp.emplace_back(d.cast<const std::vector<rectangle>&>());
return make_bounding_box_regression_training_data(truth, temp); return make_bounding_box_regression_training_data(truth, temp);
} }
...@@ -174,7 +174,7 @@ void bind_image_dataset_metadata(py::module &m_) ...@@ -174,7 +174,7 @@ void bind_image_dataset_metadata(py::module &m_)
auto partsstr = [](const std::map<std::string,point>& item) { auto partsstr = [](const std::map<std::string,point>& item) {
std::ostringstream sout; std::ostringstream sout;
sout << "{"; sout << "{";
for (auto& v : item) for (const auto& v : item)
sout << "'" << v.first << "': " << v.second << ", "; sout << "'" << v.first << "': " << v.second << ", ";
sout << "}"; sout << "}";
return sout.str(); return sout.str();
...@@ -182,7 +182,7 @@ void bind_image_dataset_metadata(py::module &m_) ...@@ -182,7 +182,7 @@ void bind_image_dataset_metadata(py::module &m_)
auto partsrepr = [](const std::map<std::string,point>& item) { auto partsrepr = [](const std::map<std::string,point>& item) {
std::ostringstream sout; std::ostringstream sout;
sout << "dlib.image_dataset_metadata.parts({\n"; 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 << "'" << v.first << "': dlib.point" << v.second << ",\n";
sout << "})"; sout << "})";
return sout.str(); return sout.str();
......
...@@ -97,12 +97,12 @@ py::list get_face_chips ( ...@@ -97,12 +97,12 @@ py::list get_face_chips (
py::list chips_list; py::list chips_list;
std::vector<chip_details> dets; std::vector<chip_details> dets;
for (auto& f : faces) for (const auto& f : faces)
dets.push_back(get_face_chip_details(f, size, padding)); dets.push_back(get_face_chip_details(f, size, padding));
dlib::array<numpy_image<rgb_pixel>> face_chips; dlib::array<numpy_image<rgb_pixel>> face_chips;
extract_image_chips(img, dets, 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 // Append image to chips list
chips_list.append(chip); chips_list.append(chip);
......
...@@ -72,7 +72,7 @@ std::shared_ptr<full_object_detection> full_obj_det_init(const rectangle& rect, ...@@ -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); const unsigned long num_parts = py::len(pyparts);
std::vector<point> parts; std::vector<point> parts;
for (auto& item : pyparts) for (const auto& item : pyparts)
parts.push_back(item.cast<point>()); parts.push_back(item.cast<point>());
return std::make_shared<full_object_detection>(rect, parts); return std::make_shared<full_object_detection>(rect, parts);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment