opencv/samples/gpu/tick_meter.hpp
Rok Mandeljc e0c8721830 samples: gpu: removed inclusion of non-existent opencv2/contrib/contrib.hpp header, re-introduced TickMeter class in a separate header
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.
2014-08-30 01:01:08 +02:00

49 lines
1.3 KiB
C++

#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