From: Vadim Pisarevsky Date: Wed, 13 Jul 2011 10:18:13 +0000 (+0000) Subject: fixed opencv_video tests X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~6641 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a69bd80b99a67c72131621df0dcce54005478e4f;p=platform%2Fupstream%2Fopencv.git fixed opencv_video tests --- diff --git a/modules/video/test/test_main.cpp b/modules/video/test/test_main.cpp index 410814c..6b24993 100644 --- a/modules/video/test/test_main.cpp +++ b/modules/video/test/test_main.cpp @@ -1,63 +1,3 @@ #include "test_precomp.hpp" -//CV_TEST_MAIN("cv") - -#if 1 -using namespace cv; - -int main(int, char**) -{ - Mat prevImg = imread("/Users/vp/work/ocv/opencv_extra/testdata/cv/optflow/rock_1.bmp", 0); - Mat nextImg = imread("/Users/vp/work/ocv/opencv_extra/testdata/cv/optflow/rock_2.bmp", 0); - FileStorage fs("/Users/vp/work/ocv/opencv_extra/testdata/cv/optflow/lk_prev.dat", FileStorage::READ); - vector u, v; - Mat _u; - fs["points"] >> _u; - _u.reshape(2, 0).copyTo(u); - vector status; - vector err; - double tmin = 0; - - for( int k = 0; k < 3; k++ ) - { - double t = (double)getTickCount(); -#if 1 - calcOpticalFlowPyrLK(prevImg, nextImg, u, v, status, err, Size(11,11), - 5, TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 30, 0.01), 100); -#else - { - CvMat _prevImg = prevImg; - CvMat _nextImg = nextImg; - v.resize(u.size()); - status.resize(u.size()); - err.resize(u.size()); - cvCalcOpticalFlowPyrLK(&_prevImg, &_nextImg, 0, 0, (CvPoint2D32f*)&u[0], (CvPoint2D32f*)&v[0], (int)u.size(), - cvSize(21, 21), 4, (char*)&status[0], - &err[0], cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 30, 0.01), 0); - } -#endif - t = (double)getTickCount() - t; - tmin = k == 0 ? t : std::min(tmin, t); - } - printf("time = %gms\n", tmin*1000./getTickFrequency()); - - Mat color; - cvtColor(prevImg, color, CV_GRAY2BGR); - for( size_t i = 0; i < u.size(); i++ ) - { - Point2f ui = u[i], vi = v[i]; - if( cvIsNaN(v[i].x) || cvIsNaN(v[i].y) || !status[i] ) - { - const float r = 2.f; - 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); - 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); - continue; - } - line(color, ui, vi, Scalar(0, 255, 0), 1); - } - imshow("flow", color); - waitKey(); - return 0; -} -#endif - +CV_TEST_MAIN("cv")