Parcourir la source

fixed a bug in the custom math functions

Helge Wrede il y a 8 ans
Parent
commit
8c005b5416

+ 1 - 1
Documentation/html/FileIO_8h_source.html

@@ -93,7 +93,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
 <div class="ttc" id="classutil_1_1FileIO_html"><div class="ttname"><a href="classutil_1_1FileIO.html">util::FileIO</a></div><div class="ttdef"><b>Definition:</b> FileIO.h:25</div></div>
 <div class="ttc" id="classutil_1_1FileIO_html_a57059c9b52e86c753db5da6281cf23c6"><div class="ttname"><a href="classutil_1_1FileIO.html#a57059c9b52e86c753db5da6281cf23c6">util::FileIO::WriteTracks</a></div><div class="ttdeci">static void WriteTracks(std::vector&lt; core::TrackletPtr &gt; &amp;tracks, const std::string &amp;file_name, char delimiter)</div><div class="ttdef"><b>Definition:</b> FileIO.cpp:315</div></div>
 <div class="ttc" id="classutil_1_1FileIO_html_a82be787051876b0e3d3c4f887c3c27ce"><div class="ttname"><a href="classutil_1_1FileIO.html#a82be787051876b0e3d3c4f887c3c27ce">util::FileIO::ReadTracks</a></div><div class="ttdeci">static void ReadTracks(std::vector&lt; core::TrackletPtr &gt; &amp;tracks, const std::string &amp;file_name, char delimiter)</div></div>
-<div class="ttc" id="classutil_1_1FileIO_html_a925a74ff26782b8f64106579c9d54b47"><div class="ttname"><a href="classutil_1_1FileIO.html#a925a74ff26782b8f64106579c9d54b47">util::FileIO::Split</a></div><div class="ttdeci">static std::vector&lt; std::string &gt; Split(const std::string &amp;input, char delimiter)</div><div class="ttdef"><b>Definition:</b> FileIO.cpp:365</div></div>
+<div class="ttc" id="classutil_1_1FileIO_html_a925a74ff26782b8f64106579c9d54b47"><div class="ttname"><a href="classutil_1_1FileIO.html#a925a74ff26782b8f64106579c9d54b47">util::FileIO::Split</a></div><div class="ttdeci">static std::vector&lt; std::string &gt; Split(const std::string &amp;input, char delimiter)</div><div class="ttdef"><b>Definition:</b> FileIO.cpp:367</div></div>
 <div class="ttc" id="classutil_1_1FileIO_html_a5f2730a95e0801faa32e49dae9b86544"><div class="ttname"><a href="classutil_1_1FileIO.html#a5f2730a95e0801faa32e49dae9b86544">util::FileIO::WriteCSVMatlab</a></div><div class="ttdeci">static void WriteCSVMatlab(DirectedGraph &amp;graph, const std::string &amp;file_name)</div><div class="ttdef"><b>Definition:</b> FileIO.cpp:146</div></div>
 <div class="ttc" id="classutil_1_1FileIO_html_ae31b9e693316483eda89df8463ea0d0a"><div class="ttname"><a href="classutil_1_1FileIO.html#ae31b9e693316483eda89df8463ea0d0a">util::FileIO::ReadCSV</a></div><div class="ttdeci">static void ReadCSV(Vector3d &amp;values, const std::string &amp;file_name, char delimiter)</div><div class="ttdef"><b>Definition:</b> FileIO.cpp:13</div></div>
 </div><!-- fragment --></div><!-- contents -->

BIN
Documentation/latex/classcore_1_1ObjectData.pdf


BIN
Documentation/latex/classcore_1_1ObjectData2D.pdf


BIN
Documentation/latex/classcore_1_1ObjectDataAngular.pdf


BIN
Documentation/latex/classcore_1_1ObjectDataBox.pdf


BIN
Documentation/latex/classcore_1_1Tracklet.pdf


+ 20 - 0
algo/Berclaz.cpp

@@ -38,6 +38,11 @@ namespace algo
 
         util::Logger::LogDebug("add edges");
 
+        double min_weight = std::numeric_limits<double>::max();
+        double max_weight = std::numeric_limits<double>::lowest();
+        double min_score = std::numeric_limits<double>::max();
+        double max_score = std::numeric_limits<double>::lowest();
+
         // Iterate all vertices but source and sink
         VertexIndexMap vertices = boost::get(boost::vertex_index, graph);
         VertexValueMap values = boost::get(boost::vertex_name, graph);
@@ -54,6 +59,13 @@ namespace algo
                     // Get the score, clamp it, prevent division by zero and
                     // logarithm of zero
                     double score = values[vi]->GetDetectionScore();
+
+                    if (score < min_score)
+                        min_score = score;
+
+                    if (score > max_score)
+                        max_score = score;
+
                     if (score > MAX_SCORE_VALUE)
                     {
                         score = MAX_SCORE_VALUE;
@@ -66,6 +78,12 @@ namespace algo
                     // Calculate the edge weight
                     double weight = -std::log(score / (1 - score));
 
+                    if (weight < min_weight)
+                        min_weight = weight;
+
+                    if (weight > max_weight)
+                        max_weight = weight;
+
                     // Connect with the next frame only if there is a next frame
                     if (z < grid.GetDepthCount() - 1)
                     {
@@ -99,6 +117,8 @@ namespace algo
             }
         }
 
+        util::Logger::LogDebug("weight " + std::to_string(min_weight) + " to " + std::to_string(max_weight));
+        util::Logger::LogDebug("score " + std::to_string(min_score) + " to " + std::to_string(max_score));
         util::Logger::LogDebug("vertex count " + std::to_string(boost::num_vertices(graph)));
         util::Logger::LogDebug("edge count " + std::to_string(boost::num_edges(graph)));
     }

+ 8 - 0
core/Tracklet.cpp

@@ -92,6 +92,14 @@ namespace core
         return path_objects_[path_objects_.size() - 1]->CompareTo(tlt->path_objects_[0]);
     }
 
+    bool Tracklet::IsWithinConstraints(ObjectDataPtr obj,
+                                       std::unordered_map<std::string, double> & constraints) const
+    {
+        TrackletPtr tlt = std::static_pointer_cast<Tracklet>(obj);
+        return path_objects_[path_objects_.size() - 1]->
+                IsWithinConstraints(tlt->path_objects_[0], constraints);
+    }
+
     ObjectDataPtr Tracklet::Interpolate(ObjectDataPtr obj, double fraction) const
     {
         TrackletPtr tlt = std::static_pointer_cast<Tracklet>(obj);

+ 2 - 0
core/Tracklet.h

@@ -122,6 +122,8 @@ namespace core
         ObjectDataPtr GetFrameObject(size_t frame_index);
 
         virtual double CompareTo(ObjectDataPtr obj) const override;
+        virtual bool IsWithinConstraints(ObjectDataPtr obj,
+                                         std::unordered_map<std::string, double> & constraints) const override;
         virtual ObjectDataPtr Interpolate(ObjectDataPtr obj, double fraction) const override;
         virtual void Visualize(cv::Mat& image, cv::Scalar& color) const override;
     };

+ 6 - 5
util/FileIO.cpp

@@ -318,12 +318,13 @@ namespace util
         // Get the frame range
         size_t first_frame = tracks[0]->GetFirstFrameIndex();
         size_t last_frame = tracks[0]->GetLastFrameIndex();
-        for (auto track : tracks)
+        for (size_t i = 1; i < tracks.size(); ++i)
         {
-            if (track->GetFirstFrameIndex() < first_frame)
-                first_frame = track->GetFirstFrameIndex();
-            if (track->GetLastFrameIndex() > last_frame)
-                last_frame = track->GetLastFrameIndex();
+            if (tracks[i]->GetFirstFrameIndex() < first_frame)
+                first_frame = tracks[i]->GetFirstFrameIndex();
+
+            if (tracks[i]->GetLastFrameIndex() > last_frame)
+                last_frame = tracks[i]->GetLastFrameIndex();
         }
 
         std::ofstream out(file_name, std::ios::out);

+ 2 - 0
util/MyMath.cpp

@@ -26,11 +26,13 @@ namespace util
 
     double MyMath::Lerp(double a, double b, double value)
     {
+        if (a == b) return a;
         return (b - a) * value + a;
     }
 
     double MyMath::InverseLerp(double a, double b, double value)
     {
+        if (a == b) return a;
         return (value - a) / (b - a);
     }
 

+ 21 - 3
util/Parser.cpp

@@ -32,7 +32,7 @@ namespace util
         util::Logger::LogInfo("Parsing ObjectData2D detections");
 
         // Calculate max and min score to normalize the score
-        double max_score = std::numeric_limits<double>::min();
+        double max_score = std::numeric_limits<double>::lowest();
         double min_score = std::numeric_limits<double>::max();
         for (size_t line_index = 0; line_index < values.size(); ++line_index)
         {
@@ -90,7 +90,7 @@ namespace util
         util::Logger::LogInfo("Parsing ObjectDataAngular detections");
 
         // Calculate max and min score to normalize the score
-        double max_score = std::numeric_limits<double>::min();
+        double max_score = std::numeric_limits<double>::lowest();
         double min_score = std::numeric_limits<double>::max();
         for (size_t line_index = 0; line_index < values.size(); ++line_index)
         {
@@ -156,7 +156,7 @@ namespace util
         util::Logger::LogInfo("Parsing ObjectDataBox detections");
 
         // Calculate max and min score to normalize the score
-        double max_score = std::numeric_limits<double>::min();
+        double max_score = std::numeric_limits<double>::lowest();
         double min_score = std::numeric_limits<double>::max();
         for (size_t line_index = 0; line_index < values.size(); ++line_index)
         {
@@ -232,6 +232,12 @@ namespace util
             }
         }
 
+        double min_score = std::numeric_limits<double>::max();
+        double max_score = std::numeric_limits<double>::lowest();
+
+        util::Logger::LogDebug("parse grid from " + std::to_string(start) +
+                                       " to " + std::to_string(stop));
+
         // Add the detections
         for (size_t f = start; f < stop; ++f)
         {
@@ -245,6 +251,15 @@ namespace util
                 double y = value->GetPosition().y;
                 double stored_score = grid.GetValue(x, y, f - start)->GetDetectionScore();
 
+                {
+                    double score = value->GetDetectionScore();
+
+                    if (score < min_score)
+                        min_score = score;
+                    if (score > max_score)
+                        max_score = score;
+                }
+
                 // Only overwrite if the new detection score is at least as good
                 // as the detection score of the already stored value
                 if (stored_score <= original_value->GetDetectionScore())
@@ -254,6 +269,9 @@ namespace util
             }
         }
 
+        util::Logger::LogDebug("scores in grid from " + std::to_string(min_score) +
+                                       " to " + std::to_string(max_score));
+
         return grid;
     }
 }