1 #include "perf_precomp.hpp"
4 using namespace testing;
8 template<> void Ptr<CvBGStatModel>::delete_obj()
10 cvReleaseBGStatModel(&obj);
16 //////////////////////////////////////////////////////
19 typedef pair<string, string> pair_string;
21 DEF_PARAM_TEST_1(ImagePair, pair_string);
23 PERF_TEST_P(ImagePair, Video_BroxOpticalFlow,
24 Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
28 cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
29 ASSERT_FALSE(frame0.empty());
31 cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
32 ASSERT_FALSE(frame1.empty());
34 frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0);
35 frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0);
39 cv::gpu::GpuMat d_frame0(frame0);
40 cv::gpu::GpuMat d_frame1(frame1);
44 cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
45 10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
47 d_flow(d_frame0, d_frame1, d_u, d_v);
51 d_flow(d_frame0, d_frame1, d_u, d_v);
54 GPU_SANITY_CHECK(d_u);
55 GPU_SANITY_CHECK(d_v);
59 FAIL() << "No such CPU implementation analogy";
63 //////////////////////////////////////////////////////
66 PERF_TEST_P(ImagePair, Video_InterpolateFrames,
67 Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
69 cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
70 ASSERT_FALSE(frame0.empty());
72 cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
73 ASSERT_FALSE(frame1.empty());
75 frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0);
76 frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0);
80 cv::gpu::GpuMat d_frame0(frame0);
81 cv::gpu::GpuMat d_frame1(frame1);
82 cv::gpu::GpuMat d_fu, d_fv;
83 cv::gpu::GpuMat d_bu, d_bv;
85 cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
86 10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
88 d_flow(d_frame0, d_frame1, d_fu, d_fv);
89 d_flow(d_frame1, d_frame0, d_bu, d_bv);
91 cv::gpu::GpuMat d_newFrame;
92 cv::gpu::GpuMat d_buf;
94 cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf);
98 cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf);
101 GPU_SANITY_CHECK(d_fu);
102 GPU_SANITY_CHECK(d_fv);
103 GPU_SANITY_CHECK(d_bu);
104 GPU_SANITY_CHECK(d_bv);
108 FAIL() << "No such CPU implementation analogy";
112 //////////////////////////////////////////////////////
113 // CreateOpticalFlowNeedleMap
115 PERF_TEST_P(ImagePair, Video_CreateOpticalFlowNeedleMap,
116 Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
118 cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
119 ASSERT_FALSE(frame0.empty());
121 cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
122 ASSERT_FALSE(frame1.empty());
124 frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0);
125 frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0);
129 cv::gpu::GpuMat d_frame0(frame0);
130 cv::gpu::GpuMat d_frame1(frame1);
134 cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
135 10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
137 d_flow(d_frame0, d_frame1, d_u, d_v);
139 cv::gpu::GpuMat d_vertex, d_colors;
141 cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors);
145 cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors);
148 GPU_SANITY_CHECK(d_vertex);
149 GPU_SANITY_CHECK(d_colors);
153 FAIL() << "No such CPU implementation analogy";
157 //////////////////////////////////////////////////////
158 // GoodFeaturesToTrack
160 DEF_PARAM_TEST(Image_MinDistance, string, double);
162 PERF_TEST_P(Image_MinDistance, Video_GoodFeaturesToTrack,
163 Combine(Values<string>("gpu/perf/aloe.png"), Values(0.0, 3.0)))
165 string fileName = GET_PARAM(0);
166 double minDistance = GET_PARAM(1);
168 cv::Mat image = readImage(fileName, cv::IMREAD_GRAYSCALE);
169 ASSERT_FALSE(image.empty());
173 cv::gpu::GoodFeaturesToTrackDetector_GPU d_detector(8000, 0.01, minDistance);
175 cv::gpu::GpuMat d_image(image);
176 cv::gpu::GpuMat d_pts;
178 d_detector(d_image, d_pts);
182 d_detector(d_image, d_pts);
185 GPU_SANITY_CHECK(d_pts);
191 cv::goodFeaturesToTrack(image, pts, 8000, 0.01, minDistance);
195 cv::goodFeaturesToTrack(image, pts, 8000, 0.01, minDistance);
198 CPU_SANITY_CHECK(pts);
202 //////////////////////////////////////////////////////
203 // PyrLKOpticalFlowSparse
205 DEF_PARAM_TEST(ImagePair_Gray_NPts_WinSz_Levels_Iters, pair_string, bool, int, int, int, int);
207 PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, Video_PyrLKOpticalFlowSparse, Combine(
208 Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")),
210 Values(1000, 2000, 4000, 8000),
211 Values(9, 13, 17, 21),
217 pair_string imagePair = GET_PARAM(0);
218 bool useGray = GET_PARAM(1);
219 int points = GET_PARAM(2);
220 int winSize = GET_PARAM(3);
221 int levels = GET_PARAM(4);
222 int iters = GET_PARAM(5);
224 cv::Mat frame0 = readImage(imagePair.first, useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR);
225 ASSERT_FALSE(frame0.empty());
227 cv::Mat frame1 = readImage(imagePair.second, useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR);
228 ASSERT_FALSE(frame1.empty());
234 cv::cvtColor(frame0, gray_frame, cv::COLOR_BGR2GRAY);
237 cv::goodFeaturesToTrack(gray_frame, pts, points, 0.01, 0.0);
241 cv::gpu::GpuMat d_pts(pts.reshape(2, 1));
243 cv::gpu::PyrLKOpticalFlow d_pyrLK;
244 d_pyrLK.winSize = cv::Size(winSize, winSize);
245 d_pyrLK.maxLevel = levels - 1;
246 d_pyrLK.iters = iters;
248 cv::gpu::GpuMat d_frame0(frame0);
249 cv::gpu::GpuMat d_frame1(frame1);
250 cv::gpu::GpuMat d_nextPts;
251 cv::gpu::GpuMat d_status;
253 d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status);
257 d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status);
260 GPU_SANITY_CHECK(d_status);
267 cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, cv::noArray(),
268 cv::Size(winSize, winSize), levels - 1,
269 cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, iters, 0.01));
273 cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, cv::noArray(),
274 cv::Size(winSize, winSize), levels - 1,
275 cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, iters, 0.01));
278 CPU_SANITY_CHECK(status);
282 //////////////////////////////////////////////////////
283 // PyrLKOpticalFlowDense
285 DEF_PARAM_TEST(ImagePair_WinSz_Levels_Iters, pair_string, int, int, int);
287 PERF_TEST_P(ImagePair_WinSz_Levels_Iters, Video_PyrLKOpticalFlowDense, Combine(
288 Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")),
289 Values(3, 5, 7, 9, 13, 17, 21),
295 pair_string imagePair = GET_PARAM(0);
296 int winSize = GET_PARAM(1);
297 int levels = GET_PARAM(2);
298 int iters = GET_PARAM(3);
300 cv::Mat frame0 = readImage(imagePair.first, cv::IMREAD_GRAYSCALE);
301 ASSERT_FALSE(frame0.empty());
303 cv::Mat frame1 = readImage(imagePair.second, cv::IMREAD_GRAYSCALE);
304 ASSERT_FALSE(frame1.empty());
308 cv::gpu::GpuMat d_frame0(frame0);
309 cv::gpu::GpuMat d_frame1(frame1);
313 cv::gpu::PyrLKOpticalFlow d_pyrLK;
314 d_pyrLK.winSize = cv::Size(winSize, winSize);
315 d_pyrLK.maxLevel = levels - 1;
316 d_pyrLK.iters = iters;
318 d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v);
322 d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v);
325 GPU_SANITY_CHECK(d_u);
326 GPU_SANITY_CHECK(d_v);
330 FAIL() << "No such CPU implementation analogy";
334 //////////////////////////////////////////////////////
335 // FarnebackOpticalFlow
337 PERF_TEST_P(ImagePair, Video_FarnebackOpticalFlow,
338 Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
342 cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
343 ASSERT_FALSE(frame0.empty());
345 cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
346 ASSERT_FALSE(frame1.empty());
349 double pyrScale = 0.5;
353 double polySigma = 1.1;
358 cv::gpu::GpuMat d_frame0(frame0);
359 cv::gpu::GpuMat d_frame1(frame1);
363 cv::gpu::FarnebackOpticalFlow d_farneback;
364 d_farneback.numLevels = numLevels;
365 d_farneback.pyrScale = pyrScale;
366 d_farneback.winSize = winSize;
367 d_farneback.numIters = numIters;
368 d_farneback.polyN = polyN;
369 d_farneback.polySigma = polySigma;
370 d_farneback.flags = flags;
372 d_farneback(d_frame0, d_frame1, d_u, d_v);
376 d_farneback(d_frame0, d_frame1, d_u, d_v);
379 GPU_SANITY_CHECK(d_u);
380 GPU_SANITY_CHECK(d_v);
386 cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags);
390 cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags);
393 CPU_SANITY_CHECK(flow);
397 //////////////////////////////////////////////////////
398 // OpticalFlowDual_TVL1
400 PERF_TEST_P(ImagePair, Video_OpticalFlowDual_TVL1,
401 Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
405 cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
406 ASSERT_FALSE(frame0.empty());
408 cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
409 ASSERT_FALSE(frame1.empty());
413 cv::gpu::GpuMat d_frame0(frame0);
414 cv::gpu::GpuMat d_frame1(frame1);
415 cv::gpu::GpuMat d_flowx;
416 cv::gpu::GpuMat d_flowy;
418 cv::gpu::OpticalFlowDual_TVL1_GPU d_alg;
420 d_alg(d_frame0, d_frame1, d_flowx, d_flowy);
424 d_alg(d_frame0, d_frame1, d_flowx, d_flowy);
427 GPU_SANITY_CHECK(d_flowx);
428 GPU_SANITY_CHECK(d_flowy);
434 cv::OpticalFlowDual_TVL1 alg;
436 alg(frame0, frame1, flow);
440 alg(frame0, frame1, flow);
443 CPU_SANITY_CHECK(flow);
447 //////////////////////////////////////////////////////
450 DEF_PARAM_TEST_1(Video, string);
452 PERF_TEST_P(Video, DISABLED_Video_FGDStatModel, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"))
456 string inputFile = perf::TestBase::getDataPath(GetParam());
458 cv::VideoCapture cap(inputFile);
459 ASSERT_TRUE(cap.isOpened());
463 ASSERT_FALSE(frame.empty());
467 cv::gpu::GpuMat d_frame(frame);
469 cv::gpu::FGDStatModel d_model(4);
470 d_model.create(d_frame);
472 for (int i = 0; i < 10; ++i)
475 ASSERT_FALSE(frame.empty());
477 d_frame.upload(frame);
479 startTimer(); next();
480 d_model.update(d_frame);
486 IplImage ipl_frame = frame;
487 cv::Ptr<CvBGStatModel> model(cvCreateFGDStatModel(&ipl_frame));
489 for (int i = 0; i < 10; ++i)
492 ASSERT_FALSE(frame.empty());
496 startTimer(); next();
497 cvUpdateBGStatModel(&ipl_frame, model);
503 //////////////////////////////////////////////////////
506 DEF_PARAM_TEST(Video_Cn_LearningRate, string, MatCn, double);
508 PERF_TEST_P(Video_Cn_LearningRate, DISABLED_Video_MOG,
509 Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4, Values(0.0, 0.01)))
511 string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
512 int cn = GET_PARAM(1);
513 float learningRate = static_cast<float>(GET_PARAM(2));
515 cv::VideoCapture cap(inputFile);
516 ASSERT_TRUE(cap.isOpened());
521 ASSERT_FALSE(frame.empty());
527 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
529 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
530 cv::swap(temp, frame);
535 cv::gpu::GpuMat d_frame(frame);
536 cv::gpu::MOG_GPU d_mog;
537 cv::gpu::GpuMat d_foreground;
539 d_mog(d_frame, d_foreground, learningRate);
541 for (int i = 0; i < 10; ++i)
544 ASSERT_FALSE(frame.empty());
550 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
552 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
553 cv::swap(temp, frame);
556 d_frame.upload(frame);
558 startTimer(); next();
559 d_mog(d_frame, d_foreground, learningRate);
565 cv::BackgroundSubtractorMOG mog;
568 mog(frame, foreground, learningRate);
570 for (int i = 0; i < 10; ++i)
573 ASSERT_FALSE(frame.empty());
579 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
581 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
582 cv::swap(temp, frame);
585 startTimer(); next();
586 mog(frame, foreground, learningRate);
592 //////////////////////////////////////////////////////
595 DEF_PARAM_TEST(Video_Cn, string, int);
597 PERF_TEST_P(Video_Cn, DISABLED_Video_MOG2,
598 Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4))
600 string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
601 int cn = GET_PARAM(1);
603 cv::VideoCapture cap(inputFile);
604 ASSERT_TRUE(cap.isOpened());
609 ASSERT_FALSE(frame.empty());
615 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
617 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
618 cv::swap(temp, frame);
623 cv::gpu::GpuMat d_frame(frame);
624 cv::gpu::MOG2_GPU d_mog2;
625 cv::gpu::GpuMat d_foreground;
627 d_mog2(d_frame, d_foreground);
629 for (int i = 0; i < 10; ++i)
632 ASSERT_FALSE(frame.empty());
638 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
640 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
641 cv::swap(temp, frame);
644 d_frame.upload(frame);
646 startTimer(); next();
647 d_mog2(d_frame, d_foreground);
653 cv::BackgroundSubtractorMOG2 mog2;
656 mog2(frame, foreground);
658 for (int i = 0; i < 10; ++i)
661 ASSERT_FALSE(frame.empty());
667 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
669 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
670 cv::swap(temp, frame);
673 startTimer(); next();
674 mog2(frame, foreground);
680 //////////////////////////////////////////////////////
681 // MOG2GetBackgroundImage
683 PERF_TEST_P(Video_Cn, Video_MOG2GetBackgroundImage,
684 Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4))
686 string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
687 int cn = GET_PARAM(1);
689 cv::VideoCapture cap(inputFile);
690 ASSERT_TRUE(cap.isOpened());
696 cv::gpu::GpuMat d_frame;
697 cv::gpu::MOG2_GPU d_mog2;
698 cv::gpu::GpuMat d_foreground;
700 for (int i = 0; i < 10; ++i)
703 ASSERT_FALSE(frame.empty());
709 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
711 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
712 cv::swap(temp, frame);
715 d_frame.upload(frame);
717 d_mog2(d_frame, d_foreground);
720 cv::gpu::GpuMat d_background;
721 d_mog2.getBackgroundImage(d_background);
725 d_mog2.getBackgroundImage(d_background);
728 GPU_SANITY_CHECK(d_background);
732 cv::BackgroundSubtractorMOG2 mog2;
735 for (int i = 0; i < 10; ++i)
738 ASSERT_FALSE(frame.empty());
744 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
746 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
747 cv::swap(temp, frame);
750 mog2(frame, foreground);
754 mog2.getBackgroundImage(background);
758 mog2.getBackgroundImage(background);
761 CPU_SANITY_CHECK(background);
765 //////////////////////////////////////////////////////
768 PERF_TEST_P(Video_Cn, DISABLED_Video_VIBE,
769 Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4))
771 string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
772 int cn = GET_PARAM(1);
774 cv::VideoCapture cap(inputFile);
775 ASSERT_TRUE(cap.isOpened());
779 ASSERT_FALSE(frame.empty());
785 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
787 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
788 cv::swap(temp, frame);
793 cv::gpu::GpuMat d_frame(frame);
794 cv::gpu::VIBE_GPU d_vibe;
795 cv::gpu::GpuMat d_foreground;
797 d_vibe(d_frame, d_foreground);
799 for (int i = 0; i < 10; ++i)
802 ASSERT_FALSE(frame.empty());
808 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
810 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
811 cv::swap(temp, frame);
814 d_frame.upload(frame);
816 startTimer(); next();
817 d_vibe(d_frame, d_foreground);
823 FAIL() << "No such CPU implementation analogy";
827 //////////////////////////////////////////////////////
830 DEF_PARAM_TEST(Video_Cn_MaxFeatures, string, MatCn, int);
832 PERF_TEST_P(Video_Cn_MaxFeatures, DISABLED_Video_GMG,
833 Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4, Values(20, 40, 60)))
835 std::string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
836 int cn = GET_PARAM(1);
837 int maxFeatures = GET_PARAM(2);
839 cv::VideoCapture cap(inputFile);
840 ASSERT_TRUE(cap.isOpened());
844 ASSERT_FALSE(frame.empty());
850 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
852 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
853 cv::swap(temp, frame);
858 cv::gpu::GpuMat d_frame(frame);
859 cv::gpu::GpuMat d_fgmask;
861 cv::gpu::GMG_GPU d_gmg;
862 d_gmg.maxFeatures = maxFeatures;
864 d_gmg(d_frame, d_fgmask);
866 for (int i = 0; i < 150; ++i)
880 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
882 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
883 cv::swap(temp, frame);
886 d_frame.upload(frame);
888 startTimer(); next();
889 d_gmg(d_frame, d_fgmask);
896 cv::Mat zeros(frame.size(), CV_8UC1, cv::Scalar::all(0));
898 cv::BackgroundSubtractorGMG gmg;
899 gmg.set("maxFeatures", maxFeatures);
900 gmg.initialize(frame.size(), 0.0, 255.0);
904 for (int i = 0; i < 150; ++i)
918 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
920 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
921 cv::swap(temp, frame);
924 startTimer(); next();
931 //////////////////////////////////////////////////////
934 PERF_TEST_P(Video, DISABLED_Video_VideoWriter, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"))
938 string inputFile = perf::TestBase::getDataPath(GetParam());
939 string outputFile = cv::tempfile(".avi");
941 const double FPS = 25.0;
943 cv::VideoCapture reader(inputFile);
944 ASSERT_TRUE( reader.isOpened() );
950 cv::gpu::VideoWriter_GPU d_writer;
952 cv::gpu::GpuMat d_frame;
954 for (int i = 0; i < 10; ++i)
957 ASSERT_FALSE(frame.empty());
959 d_frame.upload(frame);
961 if (!d_writer.isOpened())
962 d_writer.open(outputFile, frame.size(), FPS);
964 startTimer(); next();
965 d_writer.write(d_frame);
971 cv::VideoWriter writer;
973 for (int i = 0; i < 10; ++i)
976 ASSERT_FALSE(frame.empty());
978 if (!writer.isOpened())
979 writer.open(outputFile, CV_FOURCC('X', 'V', 'I', 'D'), FPS, frame.size());
981 startTimer(); next();
988 //////////////////////////////////////////////////////
991 PERF_TEST_P(Video, Video_VideoReader, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"))
995 string inputFile = perf::TestBase::getDataPath(GetParam());
999 cv::gpu::VideoReader_GPU d_reader(inputFile);
1000 ASSERT_TRUE( d_reader.isOpened() );
1002 cv::gpu::GpuMat d_frame;
1004 d_reader.read(d_frame);
1008 d_reader.read(d_frame);
1011 GPU_SANITY_CHECK(d_frame);
1015 cv::VideoCapture reader(inputFile);
1016 ASSERT_TRUE( reader.isOpened() );
1027 CPU_SANITY_CHECK(frame);