1 #ifndef OPENCV_TLD_UTILS
2 #define OPENCV_TLD_UTILS
3 
4 namespace cv {
5 inline namespace tracking {
6 namespace impl {
7 namespace tld {
8 
9 		//debug functions and variables
10 		#define ALEX_DEBUG
11 		#ifdef ALEX_DEBUG
12 		#define dfprintf(x) fprintf x
13 		#define dprintf(x) printf x
14 		#else
15 		#define dfprintf(x)
16 		#define dprintf(x)
17 		#endif
18 		#define MEASURE_TIME(a)\
19 			{\
20 			clock_t start; float milisec = 0.0; \
21 			start = clock(); {a} milisec = 1000.0 * (clock() - start) / CLOCKS_PER_SEC; \
22 			dprintf(("%-90s took %f milis\n", #a, milisec));\
23 			}
24 		#define HERE dprintf(("line %d\n", __LINE__)); fflush(stderr);
25 		#define START_TICK(name)\
26 			{ \
27 			clock_t start; double milisec = 0.0; start = clock();
28 		#define END_TICK(name) milisec = 1000.0 * (clock() - start) / CLOCKS_PER_SEC; \
29 			dprintf(("%s took %f milis\n", name, milisec)); \
30 			}
31 		extern Rect2d etalon;
32 
33 		void myassert(const Mat& img);
34 		void printPatch(const Mat_<uchar>& standardPatch);
35 		std::string type2str(const Mat& mat);
36 
37 		//aux functions and variables
CLIP(T x,T a,T b)38 		template<typename T> inline T CLIP(T x, T a, T b){ return std::min(std::max(x, a), b); }
39 		/** Computes overlap between the two given rectangles. Overlap is computed as ratio of rectangles' intersection to that
40 		* of their union.*/
41 		double overlap(const Rect2d& r1, const Rect2d& r2);
42 		/** Resamples the area surrounded by r2 in img so it matches the size of samples, where it is written.*/
43 		void resample(const Mat& img, const RotatedRect& r2, Mat_<uchar>& samples);
44 		/** Specialization of resample() for rectangles without retation for better performance and simplicity.*/
45 		void resample(const Mat& img, const Rect2d& r2, Mat_<uchar>& samples);
46 		/** Computes the variance of single given image.*/
47 		double variance(const Mat& img);
48 		void getClosestN(std::vector<Rect2d>& scanGrid, Rect2d bBox, int n, std::vector<Rect2d>& res);
49 		double scaleAndBlur(const Mat& originalImg, int scale, Mat& scaledImg, Mat& blurredImg, Size GaussBlurKernelSize, double scaleStep);
50 
51 }}}}  // namespace
52 
53 #endif
54