Skip to content

Commit a69bd80

Browse files
author
Vadim Pisarevsky
committed
fixed opencv_video tests
1 parent 6c668dd commit a69bd80

File tree

1 file changed

+1
-61
lines changed

1 file changed

+1
-61
lines changed

modules/video/test/test_main.cpp

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,3 @@
11
#include "test_precomp.hpp"
22

3-
//CV_TEST_MAIN("cv")
4-
5-
#if 1
6-
using namespace cv;
7-
8-
int main(int, char**)
9-
{
10-
Mat prevImg = imread("/Users/vp/work/ocv/opencv_extra/testdata/cv/optflow/rock_1.bmp", 0);
11-
Mat nextImg = imread("/Users/vp/work/ocv/opencv_extra/testdata/cv/optflow/rock_2.bmp", 0);
12-
FileStorage fs("/Users/vp/work/ocv/opencv_extra/testdata/cv/optflow/lk_prev.dat", FileStorage::READ);
13-
vector<Point2f> u, v;
14-
Mat _u;
15-
fs["points"] >> _u;
16-
_u.reshape(2, 0).copyTo(u);
17-
vector<uchar> status;
18-
vector<float> err;
19-
double tmin = 0;
20-
21-
for( int k = 0; k < 3; k++ )
22-
{
23-
double t = (double)getTickCount();
24-
#if 1
25-
calcOpticalFlowPyrLK(prevImg, nextImg, u, v, status, err, Size(11,11),
26-
5, TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 30, 0.01), 100);
27-
#else
28-
{
29-
CvMat _prevImg = prevImg;
30-
CvMat _nextImg = nextImg;
31-
v.resize(u.size());
32-
status.resize(u.size());
33-
err.resize(u.size());
34-
cvCalcOpticalFlowPyrLK(&_prevImg, &_nextImg, 0, 0, (CvPoint2D32f*)&u[0], (CvPoint2D32f*)&v[0], (int)u.size(),
35-
cvSize(21, 21), 4, (char*)&status[0],
36-
&err[0], cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 30, 0.01), 0);
37-
}
38-
#endif
39-
t = (double)getTickCount() - t;
40-
tmin = k == 0 ? t : std::min(tmin, t);
41-
}
42-
printf("time = %gms\n", tmin*1000./getTickFrequency());
43-
44-
Mat color;
45-
cvtColor(prevImg, color, CV_GRAY2BGR);
46-
for( size_t i = 0; i < u.size(); i++ )
47-
{
48-
Point2f ui = u[i], vi = v[i];
49-
if( cvIsNaN(v[i].x) || cvIsNaN(v[i].y) || !status[i] )
50-
{
51-
const float r = 2.f;
52-
line(color, Point2f(u[i].x-r,u[i].y-r), Point2f(u[i].x+r,u[i].y+r), Scalar(0, 0, 255), 1);
53-
line(color, Point2f(u[i].x-r,u[i].y+r), Point2f(u[i].x+r,u[i].y-r), Scalar(0, 0, 255), 1);
54-
continue;
55-
}
56-
line(color, ui, vi, Scalar(0, 255, 0), 1);
57-
}
58-
imshow("flow", color);
59-
waitKey();
60-
return 0;
61-
}
62-
#endif
63-
3+
CV_TEST_MAIN("cv")

0 commit comments

Comments
 (0)