samples: gpu: removed inclusion of non-existent opencv2/contrib/contrib.hpp header...
authorRok Mandeljc <rok.mandeljc@gmail.com>
Fri, 29 Aug 2014 22:00:11 +0000 (00:00 +0200)
committerRok Mandeljc <rok.mandeljc@gmail.com>
Fri, 29 Aug 2014 23:01:08 +0000 (01:01 +0200)
This patch removes inclusion of opencv2/contrib/contrib.hpp header,
which does not exist anymore due to removal of opencv_contrib module.

The samples including this header appear to be doing so in order to
use TickMeter class; therefore, the latter is now provided by tick_meter.hpp
header file, located in samples/gpu folder.

samples/gpu/cascadeclassifier.cpp
samples/gpu/generalized_hough.cpp
samples/gpu/stereo_multi.cpp
samples/gpu/super_resolution.cpp
samples/gpu/tick_meter.hpp [new file with mode: 0644]
samples/gpu/video_reader.cpp
samples/gpu/video_writer.cpp

index cfd32a7..dbb2895 100644 (file)
@@ -6,7 +6,6 @@
 
 #include <iostream>
 #include <iomanip>
-#include "opencv2/contrib/contrib.hpp"
 #include "opencv2/objdetect/objdetect.hpp"
 #include "opencv2/highgui/highgui.hpp"
 #include "opencv2/imgproc/imgproc.hpp"
@@ -14,6 +13,8 @@
 #include "opencv2/cudaimgproc.hpp"
 #include "opencv2/cudawarping.hpp"
 
+#include "tick_meter.hpp"
+
 using namespace std;
 using namespace cv;
 using namespace cv::cuda;
index 6803bf9..a9081c5 100644 (file)
@@ -7,7 +7,8 @@
 #include "opencv2/imgproc.hpp"
 #include "opencv2/cudaimgproc.hpp"
 #include "opencv2/highgui.hpp"
-#include "opencv2/contrib.hpp"
+
+#include "tick_meter.hpp"
 
 using namespace std;
 using namespace cv;
index bb75cf5..0997165 100644 (file)
 #include "opencv2/core.hpp"
 #include "opencv2/highgui.hpp"
 #include "opencv2/imgproc.hpp"
-#include "opencv2/contrib.hpp"
 #include "opencv2/cudastereo.hpp"
 
+#include "tick_meter.hpp"
+
 using namespace std;
 using namespace cv;
 using namespace cv::cuda;
index 4e3de21..63173cd 100644 (file)
@@ -7,11 +7,12 @@
 #include "opencv2/core/utility.hpp"
 #include "opencv2/highgui.hpp"
 #include "opencv2/imgproc.hpp"
-#include "opencv2/contrib.hpp"
 #include "opencv2/superres.hpp"
 #include "opencv2/superres/optical_flow.hpp"
 #include "opencv2/opencv_modules.hpp"
 
+#include "tick_meter.hpp"
+
 using namespace std;
 using namespace cv;
 using namespace cv::superres;
diff --git a/samples/gpu/tick_meter.hpp b/samples/gpu/tick_meter.hpp
new file mode 100644 (file)
index 0000000..d0a428b
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef OPENCV_CUDA_SAMPLES_TICKMETER_
+#define OPENCV_CUDA_SAMPLES_TICKMETER_
+
+class CV_EXPORTS TickMeter
+{
+public:
+    TickMeter();
+    void start();
+    void stop();
+
+    int64 getTimeTicks() const;
+    double getTimeMicro() const;
+    double getTimeMilli() const;
+    double getTimeSec()   const;
+    int64 getCounter() const;
+
+    void reset();
+private:
+    int64 counter;
+    int64 sumTime;
+    int64 startTime;
+};
+
+std::ostream& operator << (std::ostream& out, const TickMeter& tm);
+
+
+TickMeter::TickMeter() { reset(); }
+int64 TickMeter::getTimeTicks() const { return sumTime; }
+double TickMeter::getTimeMicro() const { return (double)getTimeTicks()/cv::getTickFrequency(); }
+double TickMeter::getTimeMilli() const { return getTimeMicro()*1e-3; }
+double TickMeter::getTimeSec() const { return getTimeMilli()*1e-3; }
+int64 TickMeter::getCounter() const { return counter; }
+void TickMeter::reset() {startTime = 0; sumTime = 0; counter = 0; }
+
+void TickMeter::start(){ startTime = cv::getTickCount(); }
+void TickMeter::stop()
+{
+    int64 time = cv::getTickCount();
+    if ( startTime == 0 )
+        return;
+    ++counter;
+    sumTime += ( time - startTime );
+    startTime = 0;
+}
+
+std::ostream& operator << (std::ostream& out, const TickMeter& tm) { return out << tm.getTimeSec() << "sec"; }
+
+#endif
index 04cf4e4..d8d6e13 100644 (file)
@@ -13,7 +13,8 @@
 #include <opencv2/core/opengl.hpp>
 #include <opencv2/cudacodec.hpp>
 #include <opencv2/highgui.hpp>
-#include <opencv2/contrib.hpp>
+
+#include "tick_meter.hpp"
 
 int main(int argc, const char* argv[])
 {
@@ -32,7 +33,7 @@ int main(int argc, const char* argv[])
     cv::cuda::GpuMat d_frame;
     cv::Ptr<cv::cudacodec::VideoReader> d_reader = cv::cudacodec::createVideoReader(fname);
 
-    cv::TickMeter tm;
+    TickMeter tm;
     std::vector<double> cpu_times;
     std::vector<double> gpu_times;
 
index 607f8d3..33d6abb 100644 (file)
@@ -10,7 +10,6 @@
 #include "opencv2/core.hpp"
 #include "opencv2/cudacodec.hpp"
 #include "opencv2/highgui.hpp"
-#include "opencv2/contrib.hpp"
 
 int main(int argc, const char* argv[])
 {