]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/commitdiff
debug: Allow setting trace float precision globally
authorMichal Sojka <michal.sojka@cvut.cz>
Thu, 4 Oct 2018 10:44:54 +0000 (12:44 +0200)
committerMichal Sojka <michal.sojka@cvut.cz>
Thu, 4 Oct 2018 10:44:54 +0000 (12:44 +0200)
src/debug.cpp
src/debug.h

index 19d5a8c3aa7632894d3b70c394aeac16d5048165..94cba134c0e411cfd5682fa9bf90c8c726d9421d 100644 (file)
@@ -4,7 +4,7 @@
 std::ostream &operator<<(std::ostream &os, const DbgTracer::Printer<cv::Mat> &p)
 {
     IOSave s(os);
-    os << std::setprecision(3);
+    os << std::setprecision(DbgTracer::precision);
     os << p.obj.size << " " << p.obj.channels() << "ch ";// << static_cast<const void *>(p.obj.data);
     os << " = [ ";
     constexpr size_t num = 10;
@@ -17,7 +17,7 @@ std::ostream &operator<<(std::ostream &os, const DbgTracer::Printer<cv::Mat> &p)
 std::ostream &operator<<(std::ostream &os, const DbgTracer::Printer<ComplexMat> &p)
 {
     IOSave s(os);
-    os << std::setprecision(3);
+    os << std::setprecision(DbgTracer::precision);
     os << "<cplx> " << p.obj.size() << " " << p.obj.channels() << "ch "; // << p.obj.get_p_data();
     constexpr int num = 10;
     for (uint s = 0; s < p.obj.n_scales; ++s) {
index 73ff1e95e292f81ccf1e2e6caaa03565c9e82044..6ad1d18c1d70ffd17a7f42d12619e0fb2e93c5df 100644 (file)
@@ -41,6 +41,7 @@ class DbgTracer {
 
   public:
     bool debug = false;
+    static constexpr int precision = 2;
 
     std::string indent() { return std::string(indentLvl * 4, ' '); }
 
@@ -78,6 +79,8 @@ class DbgTracer {
 #ifdef CUFFT
             CudaSafeCall(cudaStreamSynchronize(cudaStreamPerThread));
 #endif
+            IOSave s(std::cerr);
+            std::cerr << std::setprecision(precision);
             std::cerr << indent() << name /*<< " @" << line */ << " " << print(obj) << std::endl;
         }
     }