From 2b2c6f01e918fc32d272c7d3bfb8fa3ecf805843 Mon Sep 17 00:00:00 2001 From: Davis King Date: Sat, 27 Feb 2016 19:47:56 -0500 Subject: [PATCH 1/5] Made the rectangle have an operator< rather than overloading std::less since the former works with a wider range of tools in the STL. --- dlib/geometry/rectangle.h | 36 +++++++++++------------------- dlib/geometry/rectangle_abstract.h | 33 +++++++++------------------ 2 files changed, 23 insertions(+), 46 deletions(-) diff --git a/dlib/geometry/rectangle.h b/dlib/geometry/rectangle.h index c4c71106b..7e7bb781b 100644 --- a/dlib/geometry/rectangle.h +++ b/dlib/geometry/rectangle.h @@ -260,6 +260,19 @@ namespace dlib return !(*this == rect); } + inline bool operator< (const dlib::rectangle& b) const + { + if (left() < b.left()) return true; + else if (left() > b.left()) return false; + else if (top() < b.top()) return true; + else if (top() > b.top()) return false; + else if (right() < b.right()) return true; + else if (right() > b.right()) return false; + else if (bottom() < b.bottom()) return true; + else if (bottom() > b.bottom()) return false; + else return false; + } + private: long l; long t; @@ -753,29 +766,6 @@ namespace dlib } -namespace std -{ - /*! - Define std::less so that you can use rectangles in the associative containers. - !*/ - template<> - struct less : public binary_function - { - inline bool operator() (const dlib::rectangle& a, const dlib::rectangle& b) const - { - if (a.left() < b.left()) return true; - else if (a.left() > b.left()) return false; - else if (a.top() < b.top()) return true; - else if (a.top() > b.top()) return false; - else if (a.right() < b.right()) return true; - else if (a.right() > b.right()) return false; - else if (a.bottom() < b.bottom()) return true; - else if (a.bottom() > b.bottom()) return false; - else return false; - } - }; -} - #endif // DLIB_RECTANGLe_ diff --git a/dlib/geometry/rectangle_abstract.h b/dlib/geometry/rectangle_abstract.h index 08e860494..1c1e89089 100644 --- a/dlib/geometry/rectangle_abstract.h +++ b/dlib/geometry/rectangle_abstract.h @@ -363,6 +363,16 @@ namespace dlib ensures - returns !(*this == rect) !*/ + + bool operator< ( + const dlib::rectangle& a, + const dlib::rectangle& b + ) const; + /*! + ensures + - Defines a total ordering over rectangles so they can be used in + associative containers. + !*/ }; // ---------------------------------------------------------------------------------------- @@ -789,28 +799,5 @@ namespace dlib } -namespace std -{ - /*! - Define std::less so that you can use rectangles in the associative containers. - !*/ - template<> - struct less : public binary_function - { - inline bool operator() (const dlib::rectangle& a, const dlib::rectangle& b) const - { - if (a.left() < b.left()) return true; - else if (a.left() > b.left()) return false; - else if (a.top() < b.top()) return true; - else if (a.top() > b.top()) return false; - else if (a.right() < b.right()) return true; - else if (a.right() > b.right()) return false; - else if (a.bottom() < b.bottom()) return true; - else if (a.bottom() > b.bottom()) return false; - else return false; - } - }; -} - #endif // DLIB_RECTANGLe_ABSTRACT_ From 33c8d0c2d4a41dce2fa5bc6fa65e2c3fe9bf9909 Mon Sep 17 00:00:00 2001 From: Davis King Date: Sat, 27 Feb 2016 19:48:20 -0500 Subject: [PATCH 2/5] Added pose and detection scores to the box object. --- dlib/data_io/image_dataset_metadata.cpp | 6 ++++++ dlib/data_io/image_dataset_metadata.h | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/dlib/data_io/image_dataset_metadata.cpp b/dlib/data_io/image_dataset_metadata.cpp index a7d6f3235..65bef818f 100644 --- a/dlib/data_io/image_dataset_metadata.cpp +++ b/dlib/data_io/image_dataset_metadata.cpp @@ -80,6 +80,10 @@ namespace dlib fout << " ignore='" << b.ignore << "'"; if (b.angle != 0) fout << " angle='" << b.angle << "'"; + if (b.pose != 0) + fout << " pose='" << b.pose << "'"; + if (b.detection_score != 0) + fout << " detection_score='" << b.detection_score << "'"; if (b.has_label() || b.parts.size() != 0) { @@ -192,6 +196,8 @@ namespace dlib if (atts.is_in_list("occluded")) temp_box.occluded = sa = atts["occluded"]; if (atts.is_in_list("ignore")) temp_box.ignore = sa = atts["ignore"]; if (atts.is_in_list("angle")) temp_box.angle = sa = atts["angle"]; + if (atts.is_in_list("pose")) temp_box.pose = sa = atts["pose"]; + if (atts.is_in_list("detection_score")) temp_box.detection_score = sa = atts["detection_score"]; temp_box.rect.bottom() += temp_box.rect.top()-1; temp_box.rect.right() += temp_box.rect.left()-1; diff --git a/dlib/data_io/image_dataset_metadata.h b/dlib/data_io/image_dataset_metadata.h index b052ed1cc..da239e4a8 100644 --- a/dlib/data_io/image_dataset_metadata.h +++ b/dlib/data_io/image_dataset_metadata.h @@ -45,7 +45,9 @@ namespace dlib truncated(false), occluded(false), ignore(false), - angle(0) + angle(0), + pose(0), + detection_score(0) {} rectangle rect; @@ -58,6 +60,8 @@ namespace dlib bool truncated; bool occluded; bool ignore; + double pose; + double detection_score; // The angle of the object in radians. Positive values indicate that the // object at the center of the box is rotated clockwise by angle radians. A From d4f6e5f1bf6d0d1aaf2f2e2203cfaf338ad864ce Mon Sep 17 00:00:00 2001 From: Davis King Date: Sun, 28 Feb 2016 07:31:08 -0500 Subject: [PATCH 3/5] Fixed missing initializers. --- dlib/data_io/image_dataset_metadata.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dlib/data_io/image_dataset_metadata.h b/dlib/data_io/image_dataset_metadata.h index da239e4a8..08c298423 100644 --- a/dlib/data_io/image_dataset_metadata.h +++ b/dlib/data_io/image_dataset_metadata.h @@ -34,7 +34,9 @@ namespace dlib truncated(false), occluded(false), ignore(false), - angle(0) + angle(0), + pose(0), + detection_score(0) {} box ( From 564d5b76b141d0fa44010a1dc800ed13f7badcbe Mon Sep 17 00:00:00 2001 From: Davis King Date: Sun, 28 Feb 2016 11:37:01 -0500 Subject: [PATCH 4/5] fixed xml errors --- docs/docs/optimization.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docs/optimization.xml b/docs/docs/optimization.xml index b0559b358..cd71818fd 100644 --- a/docs/docs/optimization.xml +++ b/docs/docs/optimization.xml @@ -507,9 +507,9 @@ subject to the following constraint: 0.5*trans(lambda)*lambda - trans(lambda)*A*alpha - trans(lambda)*d subject to the following constraints: sum(alpha) == C - min(alpha) >= 0 - min(lambda) >= 0 - max(lambda) <= max_lambda + min(alpha) >= 0 + min(lambda) >= 0 + max(lambda) <= max_lambda Where f is convex. This means that Q should be positive-semidefinite. From 575341305c618bb863900375d8800a8370e69294 Mon Sep 17 00:00:00 2001 From: Davis King Date: Sun, 28 Feb 2016 11:37:12 -0500 Subject: [PATCH 5/5] Added new FAQ --- docs/docs/faq.xml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/docs/docs/faq.xml b/docs/docs/faq.xml index a963819a0..bfeeabb68 100644 --- a/docs/docs/faq.xml +++ b/docs/docs/faq.xml @@ -7,6 +7,42 @@ + + Do not post a question like "I'm using dlib, and it doesn't work?" or + "I'm using the object detector and it doesn't work, what do I do?". + If this is all you say then I have no idea what is wrong. 99% of the + time it's some kind of user error. 1% of the time it's some problem + in dlib. But again, without more information it's impossible to know. + So please don't post questions like this. + +

+ If you think you found some kind of bug or problem in dlib then feel + free to post on sourceforge + or github. + But include the version of dlib you are using, what you + are trying, what happened, what you expected to have happened instead, etc. +

+ +

+ On the other hand, if you haven't found a bug or problem in dlib, but + instead are looking for machine learning/computer vision/programming + consulting then you can still post your question on sourceforge. + But be clear that this is what you are asking for. Maybe someone will + help you or you can find someone to pay money in exchange for a + solution to your problem. +

+ +

+ However, don't try to get someone to write your code for you by + repeatedly asking a question like "ok, what do I type next to make a + program that does X?". I get this question all the time from people + who obviously don't know how to program. If you are not familiar + with C++ it's much better to learn it by + reading one of the excellent books on the topic + than by an infinite sequence of questions posted in the dlib forums. +

+ +
There are instructions on the How to Compile page.