]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/commitdiff
debug: Round low values to zero when printing them
authorMichal Sojka <michal.sojka@cvut.cz>
Thu, 4 Oct 2018 11:01:36 +0000 (13:01 +0200)
committerMichal Sojka <michal.sojka@cvut.cz>
Thu, 4 Oct 2018 11:01:36 +0000 (13:01 +0200)
This is to make comparison of outputs of different implementations easier.

src/debug.cpp

index 94cba134c0e411cfd5682fa9bf90c8c726d9421d..7a09f4c09719da0d1b847f6a2648a37931be89c5 100644 (file)
@@ -23,8 +23,14 @@ std::ostream &operator<<(std::ostream &os, const DbgTracer::Printer<ComplexMat>
     for (uint s = 0; s < p.obj.n_scales; ++s) {
         uint ofs = s * p.obj.rows * p.obj.cols * p.obj.n_channels / p.obj.n_scales;
         os << " = [ ";
-        for (int i = 0; i < std::min(num, p.obj.size().area()); ++i)
-            os << p.obj.get_p_data()[ofs + i] << ", ";
+        for (int i = 0; i < std::min(num, p.obj.size().area()); ++i) {
+            std::complex<float> c = p.obj.get_p_data()[ofs + i];
+            if (fabs(c.real()) < 5e-7)
+                c = std::complex<float>(0, c.imag());
+            if (fabs(c.imag()) < 5e-7)
+                c = std::complex<float>(c.real(), 0);
+            os << c << ", ";
+        }
         os << (num < p.obj.size().area() ? "... ]" : "]");
         os << std::endl << std::string(20, ' ');
     }