]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/blobdiff - src/debug.h
Make KCF member variables constexpr where possible
[hercules2020/kcf.git] / src / debug.h
index c9a3b94e3c449877bfbcb9007e53e67ef223d1c4..cce8327201b44732d131ff4f080a01bed7813180 100644 (file)
@@ -7,10 +7,11 @@
 #include <stdio.h>
 #include <opencv2/opencv.hpp>
 #include "dynmem.hpp"
-#ifdef CUFFT
-#include "complexmat.cuh"
-#else
 #include "complexmat.hpp"
+
+#ifdef CUFFT
+#include <cufft.h>
+#include "nvToolsExt.h"
 #endif
 
 
@@ -41,6 +42,7 @@ class DbgTracer {
 
   public:
     bool debug = false;
+    static constexpr int precision = 2;
 
     std::string indent() { return std::string(indentLvl * 4, ' '); }
 
@@ -51,6 +53,9 @@ class DbgTracer {
       public:
         FTrace(DbgTracer &dt, const char *fn, const char *format, ...) : t(dt), funcName(fn)
         {
+#ifdef CUFFT
+            nvtxRangePushA(fn);
+#endif
             if (!t.debug) return;
             char *arg;
             va_list vl;
@@ -64,6 +69,9 @@ class DbgTracer {
         }
         ~FTrace()
         {
+#ifdef CUFFT
+            nvtxRangePop();
+#endif
             if (!t.debug) return;
             t.indentLvl--;
             std::cerr << t.indent() << "}" << std::endl;
@@ -71,11 +79,14 @@ class DbgTracer {
     };
 
     template <typename T>
-    void traceVal(const char *name, const T& obj, int line)
+    void traceVal(const char *name, const T& obj, int line, bool always = false)
     {
         (void)line;
-        if (debug)
+        if (debug || always) {
+            IOSave s(std::cerr);
+            std::cerr << std::setprecision(precision);
             std::cerr << indent() << name /*<< " @" << line */ << " " << print(obj) << std::endl;
+        }
     }
 
     template <typename T> struct Printer {
@@ -96,7 +107,7 @@ std::ostream &operator<<(std::ostream &os, const DbgTracer::Printer<T> &p)
     return os;
 }
 
-#if CV_VERSION_MAJOR < 3 || CV_VERSION_MINOR < 3
+#if CV_MAJOR_VERSION == 3 && CV_MINOR_VERSION < 3
 static inline std::ostream &operator<<(std::ostream &out, const cv::MatSize &msize)
 {
     int i, dims = msize.p[-1];
@@ -127,5 +138,6 @@ extern DbgTracer __dbgTracer;
 
 #define DEBUG_PRINT(obj) __dbgTracer.traceVal(#obj, (obj), __LINE__)
 #define DEBUG_PRINTM(obj) DEBUG_PRINT(obj)
+#define PRINT(obj) __dbgTracer.traceVal(#obj, (obj), __LINE__, true)
 
 #endif // DEBUG_H