1 #include "perf_precomp.hpp"
\r
4 using namespace testing;
\r
8 template<> void Ptr<CvBGStatModel>::delete_obj()
\r
10 cvReleaseBGStatModel(&obj);
\r
16 //////////////////////////////////////////////////////
\r
19 typedef pair<string, string> pair_string;
\r
21 DEF_PARAM_TEST_1(ImagePair, pair_string);
\r
23 PERF_TEST_P(ImagePair, Video_BroxOpticalFlow, Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
\r
27 cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
\r
28 ASSERT_FALSE(frame0.empty());
\r
30 cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
\r
31 ASSERT_FALSE(frame1.empty());
\r
33 frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0);
\r
34 frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0);
\r
38 cv::gpu::GpuMat d_frame0(frame0);
\r
39 cv::gpu::GpuMat d_frame1(frame1);
\r
40 cv::gpu::GpuMat d_u;
\r
41 cv::gpu::GpuMat d_v;
\r
43 cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
\r
44 10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
\r
46 d_flow(d_frame0, d_frame1, d_u, d_v);
\r
50 d_flow(d_frame0, d_frame1, d_u, d_v);
\r
59 //////////////////////////////////////////////////////
\r
60 // InterpolateFrames
\r
62 PERF_TEST_P(ImagePair, Video_InterpolateFrames, Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
\r
64 cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
\r
65 ASSERT_FALSE(frame0.empty());
\r
67 cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
\r
68 ASSERT_FALSE(frame1.empty());
\r
70 frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0);
\r
71 frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0);
\r
75 cv::gpu::GpuMat d_frame0(frame0);
\r
76 cv::gpu::GpuMat d_frame1(frame1);
\r
77 cv::gpu::GpuMat d_fu, d_fv;
\r
78 cv::gpu::GpuMat d_bu, d_bv;
\r
80 cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
\r
81 10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
\r
83 d_flow(d_frame0, d_frame1, d_fu, d_fv);
\r
84 d_flow(d_frame1, d_frame0, d_bu, d_bv);
\r
86 cv::gpu::GpuMat d_newFrame;
\r
87 cv::gpu::GpuMat d_buf;
\r
89 cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf);
\r
93 cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf);
\r
102 //////////////////////////////////////////////////////
\r
103 // CreateOpticalFlowNeedleMap
\r
105 PERF_TEST_P(ImagePair, Video_CreateOpticalFlowNeedleMap, Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
\r
107 cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
\r
108 ASSERT_FALSE(frame0.empty());
\r
110 cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
\r
111 ASSERT_FALSE(frame1.empty());
\r
113 frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0);
\r
114 frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0);
\r
118 cv::gpu::GpuMat d_frame0(frame0);
\r
119 cv::gpu::GpuMat d_frame1(frame1);
\r
120 cv::gpu::GpuMat d_u;
\r
121 cv::gpu::GpuMat d_v;
\r
123 cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
\r
124 10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
\r
126 d_flow(d_frame0, d_frame1, d_u, d_v);
\r
128 cv::gpu::GpuMat d_vertex, d_colors;
\r
130 cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors);
\r
134 cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors);
\r
143 //////////////////////////////////////////////////////
\r
144 // GoodFeaturesToTrack
\r
146 DEF_PARAM_TEST(Image_MinDistance, string, double);
\r
148 PERF_TEST_P(Image_MinDistance, Video_GoodFeaturesToTrack, Combine(Values<string>("gpu/perf/aloe.jpg"), Values(0.0, 3.0)))
\r
150 string fileName = GET_PARAM(0);
\r
151 double minDistance = GET_PARAM(1);
\r
153 cv::Mat image = readImage(fileName, cv::IMREAD_GRAYSCALE);
\r
154 ASSERT_FALSE(image.empty());
\r
158 cv::gpu::GoodFeaturesToTrackDetector_GPU d_detector(8000, 0.01, minDistance);
\r
160 cv::gpu::GpuMat d_image(image);
\r
161 cv::gpu::GpuMat d_pts;
\r
163 d_detector(d_image, d_pts);
\r
167 d_detector(d_image, d_pts);
\r
174 cv::goodFeaturesToTrack(image, pts, 8000, 0.01, minDistance);
\r
178 cv::goodFeaturesToTrack(image, pts, 8000, 0.01, minDistance);
\r
183 //////////////////////////////////////////////////////
\r
184 // PyrLKOpticalFlowSparse
\r
186 DEF_PARAM_TEST(ImagePair_Gray_NPts_WinSz_Levels_Iters, pair_string, bool, int, int, int, int);
\r
188 PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, Video_PyrLKOpticalFlowSparse, Combine(
\r
189 Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")),
\r
191 Values(1000, 2000, 4000, 8000),
\r
192 Values(9, 13, 17, 21),
\r
194 Values(1, 10, 30)))
\r
196 declare.time(20.0);
\r
198 pair_string imagePair = GET_PARAM(0);
\r
199 bool useGray = GET_PARAM(1);
\r
200 int points = GET_PARAM(2);
\r
201 int winSize = GET_PARAM(3);
\r
202 int levels = GET_PARAM(4);
\r
203 int iters = GET_PARAM(5);
\r
205 cv::Mat frame0 = readImage(imagePair.first, useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR);
\r
206 ASSERT_FALSE(frame0.empty());
\r
208 cv::Mat frame1 = readImage(imagePair.second, useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR);
\r
209 ASSERT_FALSE(frame1.empty());
\r
211 cv::Mat gray_frame;
\r
213 gray_frame = frame0;
\r
215 cv::cvtColor(frame0, gray_frame, cv::COLOR_BGR2GRAY);
\r
218 cv::goodFeaturesToTrack(gray_frame, pts, points, 0.01, 0.0);
\r
222 cv::gpu::GpuMat d_pts(pts);
\r
224 cv::gpu::PyrLKOpticalFlow d_pyrLK;
\r
225 d_pyrLK.winSize = cv::Size(winSize, winSize);
\r
226 d_pyrLK.maxLevel = levels - 1;
\r
227 d_pyrLK.iters = iters;
\r
229 cv::gpu::GpuMat d_frame0(frame0);
\r
230 cv::gpu::GpuMat d_frame1(frame1);
\r
231 cv::gpu::GpuMat d_nextPts;
\r
232 cv::gpu::GpuMat d_status;
\r
234 d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status);
\r
238 d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status);
\r
246 cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, cv::noArray(),
\r
247 cv::Size(winSize, winSize), levels - 1,
\r
248 cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, iters, 0.01));
\r
252 cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, cv::noArray(),
\r
253 cv::Size(winSize, winSize), levels - 1,
\r
254 cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, iters, 0.01));
\r
259 //////////////////////////////////////////////////////
\r
260 // PyrLKOpticalFlowDense
\r
262 DEF_PARAM_TEST(ImagePair_WinSz_Levels_Iters, pair_string, int, int, int);
\r
264 PERF_TEST_P(ImagePair_WinSz_Levels_Iters, Video_PyrLKOpticalFlowDense, Combine(
\r
265 Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")),
\r
266 Values(3, 5, 7, 9, 13, 17, 21),
\r
272 pair_string imagePair = GET_PARAM(0);
\r
273 int winSize = GET_PARAM(1);
\r
274 int levels = GET_PARAM(2);
\r
275 int iters = GET_PARAM(3);
\r
277 cv::Mat frame0 = readImage(imagePair.first, cv::IMREAD_GRAYSCALE);
\r
278 ASSERT_FALSE(frame0.empty());
\r
280 cv::Mat frame1 = readImage(imagePair.second, cv::IMREAD_GRAYSCALE);
\r
281 ASSERT_FALSE(frame1.empty());
\r
285 cv::gpu::GpuMat d_frame0(frame0);
\r
286 cv::gpu::GpuMat d_frame1(frame1);
\r
287 cv::gpu::GpuMat d_u;
\r
288 cv::gpu::GpuMat d_v;
\r
290 cv::gpu::PyrLKOpticalFlow d_pyrLK;
\r
291 d_pyrLK.winSize = cv::Size(winSize, winSize);
\r
292 d_pyrLK.maxLevel = levels - 1;
\r
293 d_pyrLK.iters = iters;
\r
295 d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v);
\r
299 d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v);
\r
308 //////////////////////////////////////////////////////
\r
309 // FarnebackOpticalFlow
\r
311 PERF_TEST_P(ImagePair, Video_FarnebackOpticalFlow, Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
\r
315 cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
\r
316 ASSERT_FALSE(frame0.empty());
\r
318 cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
\r
319 ASSERT_FALSE(frame1.empty());
\r
322 double pyrScale = 0.5;
\r
326 double polySigma = 1.1;
\r
331 cv::gpu::GpuMat d_frame0(frame0);
\r
332 cv::gpu::GpuMat d_frame1(frame1);
\r
333 cv::gpu::GpuMat d_u;
\r
334 cv::gpu::GpuMat d_v;
\r
336 cv::gpu::FarnebackOpticalFlow d_farneback;
\r
337 d_farneback.numLevels = numLevels;
\r
338 d_farneback.pyrScale = pyrScale;
\r
339 d_farneback.winSize = winSize;
\r
340 d_farneback.numIters = numIters;
\r
341 d_farneback.polyN = polyN;
\r
342 d_farneback.polySigma = polySigma;
\r
343 d_farneback.flags = flags;
\r
345 d_farneback(d_frame0, d_frame1, d_u, d_v);
\r
349 d_farneback(d_frame0, d_frame1, d_u, d_v);
\r
356 cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags);
\r
360 cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags);
\r
365 //////////////////////////////////////////////////////
\r
368 DEF_PARAM_TEST_1(Video, string);
\r
370 PERF_TEST_P(Video, Video_FGDStatModel, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"))
\r
374 string inputFile = perf::TestBase::getDataPath(GetParam());
\r
376 cv::VideoCapture cap(inputFile);
\r
377 ASSERT_TRUE(cap.isOpened());
\r
381 ASSERT_FALSE(frame.empty());
\r
385 cv::gpu::GpuMat d_frame(frame);
\r
387 cv::gpu::FGDStatModel d_model(4);
\r
388 d_model.create(d_frame);
\r
390 for (int i = 0; i < 10; ++i)
\r
393 ASSERT_FALSE(frame.empty());
\r
395 d_frame.upload(frame);
\r
397 startTimer(); next();
\r
398 d_model.update(d_frame);
\r
404 IplImage ipl_frame = frame;
\r
405 cv::Ptr<CvBGStatModel> model(cvCreateFGDStatModel(&ipl_frame));
\r
407 for (int i = 0; i < 10; ++i)
\r
410 ASSERT_FALSE(frame.empty());
\r
414 startTimer(); next();
\r
415 cvUpdateBGStatModel(&ipl_frame, model);
\r
421 //////////////////////////////////////////////////////
\r
424 DEF_PARAM_TEST(Video_Cn_LearningRate, string, int, double);
\r
426 PERF_TEST_P(Video_Cn_LearningRate, Video_MOG, Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), Values(1, 3, 4), Values(0.0, 0.01)))
\r
428 string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
\r
429 int cn = GET_PARAM(1);
\r
430 float learningRate = static_cast<float>(GET_PARAM(2));
\r
432 cv::VideoCapture cap(inputFile);
\r
433 ASSERT_TRUE(cap.isOpened());
\r
438 ASSERT_FALSE(frame.empty());
\r
444 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
\r
446 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
\r
447 cv::swap(temp, frame);
\r
452 cv::gpu::GpuMat d_frame(frame);
\r
453 cv::gpu::MOG_GPU d_mog;
\r
454 cv::gpu::GpuMat d_foreground;
\r
456 d_mog(d_frame, d_foreground, learningRate);
\r
458 for (int i = 0; i < 10; ++i)
\r
461 ASSERT_FALSE(frame.empty());
\r
467 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
\r
469 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
\r
470 cv::swap(temp, frame);
\r
473 d_frame.upload(frame);
\r
475 startTimer(); next();
\r
476 d_mog(d_frame, d_foreground, learningRate);
\r
482 cv::BackgroundSubtractorMOG mog;
\r
483 cv::Mat foreground;
\r
485 mog(frame, foreground, learningRate);
\r
487 for (int i = 0; i < 10; ++i)
\r
490 ASSERT_FALSE(frame.empty());
\r
496 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
\r
498 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
\r
499 cv::swap(temp, frame);
\r
502 startTimer(); next();
\r
503 mog(frame, foreground, learningRate);
\r
509 //////////////////////////////////////////////////////
\r
512 DEF_PARAM_TEST(Video_Cn, string, int);
\r
514 PERF_TEST_P(Video_Cn, Video_MOG2, Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), Values(1, 3, 4)))
\r
516 string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
\r
517 int cn = GET_PARAM(1);
\r
519 cv::VideoCapture cap(inputFile);
\r
520 ASSERT_TRUE(cap.isOpened());
\r
525 ASSERT_FALSE(frame.empty());
\r
531 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
\r
533 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
\r
534 cv::swap(temp, frame);
\r
539 cv::gpu::GpuMat d_frame(frame);
\r
540 cv::gpu::MOG2_GPU d_mog2;
\r
541 cv::gpu::GpuMat d_foreground;
\r
543 d_mog2(d_frame, d_foreground);
\r
545 for (int i = 0; i < 10; ++i)
\r
548 ASSERT_FALSE(frame.empty());
\r
554 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
\r
556 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
\r
557 cv::swap(temp, frame);
\r
560 d_frame.upload(frame);
\r
562 startTimer(); next();
\r
563 d_mog2(d_frame, d_foreground);
\r
569 cv::BackgroundSubtractorMOG2 mog2;
\r
570 cv::Mat foreground;
\r
572 mog2(frame, foreground);
\r
574 for (int i = 0; i < 10; ++i)
\r
577 ASSERT_FALSE(frame.empty());
\r
583 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
\r
585 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
\r
586 cv::swap(temp, frame);
\r
589 startTimer(); next();
\r
590 mog2(frame, foreground);
\r
596 //////////////////////////////////////////////////////
\r
597 // MOG2GetBackgroundImage
\r
599 PERF_TEST_P(Video_Cn, Video_MOG2GetBackgroundImage, Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), Values(1, 3, 4)))
\r
601 string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
\r
602 int cn = GET_PARAM(1);
\r
604 cv::VideoCapture cap(inputFile);
\r
605 ASSERT_TRUE(cap.isOpened());
\r
611 cv::gpu::GpuMat d_frame;
\r
612 cv::gpu::MOG2_GPU d_mog2;
\r
613 cv::gpu::GpuMat d_foreground;
\r
615 for (int i = 0; i < 10; ++i)
\r
618 ASSERT_FALSE(frame.empty());
\r
624 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
\r
626 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
\r
627 cv::swap(temp, frame);
\r
630 d_frame.upload(frame);
\r
632 d_mog2(d_frame, d_foreground);
\r
635 cv::gpu::GpuMat d_background;
\r
636 d_mog2.getBackgroundImage(d_background);
\r
640 d_mog2.getBackgroundImage(d_background);
\r
645 cv::BackgroundSubtractorMOG2 mog2;
\r
646 cv::Mat foreground;
\r
648 for (int i = 0; i < 10; ++i)
\r
651 ASSERT_FALSE(frame.empty());
\r
657 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
\r
659 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
\r
660 cv::swap(temp, frame);
\r
663 mog2(frame, foreground);
\r
666 cv::Mat background;
\r
667 mog2.getBackgroundImage(background);
\r
671 mog2.getBackgroundImage(background);
\r
676 //////////////////////////////////////////////////////
\r
679 PERF_TEST_P(Video_Cn, Video_VIBE, Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), Values(1, 3, 4)))
\r
681 string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
\r
682 int cn = GET_PARAM(1);
\r
684 cv::VideoCapture cap(inputFile);
\r
685 ASSERT_TRUE(cap.isOpened());
\r
689 ASSERT_FALSE(frame.empty());
\r
695 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
\r
697 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
\r
698 cv::swap(temp, frame);
\r
703 cv::gpu::GpuMat d_frame(frame);
\r
704 cv::gpu::VIBE_GPU d_vibe;
\r
705 cv::gpu::GpuMat d_foreground;
\r
707 d_vibe(d_frame, d_foreground);
\r
709 for (int i = 0; i < 10; ++i)
\r
712 ASSERT_FALSE(frame.empty());
\r
718 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
\r
720 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
\r
721 cv::swap(temp, frame);
\r
724 d_frame.upload(frame);
\r
726 startTimer(); next();
\r
727 d_vibe(d_frame, d_foreground);
\r
737 //////////////////////////////////////////////////////
\r
740 DEF_PARAM_TEST(Video_Cn_MaxFeatures, string, int, int);
\r
742 PERF_TEST_P(Video_Cn_MaxFeatures, Video_GMG, Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), Values(1, 3, 4), Values(20, 40, 60)))
\r
744 std::string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
\r
745 int cn = GET_PARAM(1);
\r
746 int maxFeatures = GET_PARAM(2);
\r
748 cv::VideoCapture cap(inputFile);
\r
749 ASSERT_TRUE(cap.isOpened());
\r
753 ASSERT_FALSE(frame.empty());
\r
759 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
\r
761 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
\r
762 cv::swap(temp, frame);
\r
767 cv::gpu::GpuMat d_frame(frame);
\r
768 cv::gpu::GpuMat d_fgmask;
\r
770 cv::gpu::GMG_GPU d_gmg;
\r
771 d_gmg.maxFeatures = maxFeatures;
\r
773 d_gmg(d_frame, d_fgmask);
\r
775 for (int i = 0; i < 150; ++i)
\r
780 cap.open(inputFile);
\r
788 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
\r
790 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
\r
791 cv::swap(temp, frame);
\r
794 d_frame.upload(frame);
\r
796 startTimer(); next();
\r
797 d_gmg(d_frame, d_fgmask);
\r
804 cv::Mat zeros(frame.size(), CV_8UC1, cv::Scalar::all(0));
\r
806 cv::BackgroundSubtractorGMG gmg;
\r
807 gmg.set("maxFeatures", maxFeatures);
\r
808 gmg.initialize(frame.size(), 0.0, 255.0);
\r
810 gmg(frame, fgmask);
\r
812 for (int i = 0; i < 150; ++i)
\r
817 cap.open(inputFile);
\r
825 cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
\r
827 cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
\r
828 cv::swap(temp, frame);
\r
831 startTimer(); next();
\r
832 gmg(frame, fgmask);
\r
838 //////////////////////////////////////////////////////
\r
841 PERF_TEST_P(Video, Video_VideoWriter, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"))
\r
845 string inputFile = perf::TestBase::getDataPath(GetParam());
\r
846 string outputFile = cv::tempfile(".avi");
\r
848 const double FPS = 25.0;
\r
850 cv::VideoCapture reader(inputFile);
\r
851 ASSERT_TRUE( reader.isOpened() );
\r
857 cv::gpu::VideoWriter_GPU d_writer;
\r
859 cv::gpu::GpuMat d_frame;
\r
861 for (int i = 0; i < 10; ++i)
\r
864 ASSERT_FALSE(frame.empty());
\r
866 d_frame.upload(frame);
\r
868 if (!d_writer.isOpened())
\r
869 d_writer.open(outputFile, frame.size(), FPS);
\r
871 startTimer(); next();
\r
872 d_writer.write(d_frame);
\r
878 cv::VideoWriter writer;
\r
880 for (int i = 0; i < 10; ++i)
\r
883 ASSERT_FALSE(frame.empty());
\r
885 if (!writer.isOpened())
\r
886 writer.open(outputFile, CV_FOURCC('X', 'V', 'I', 'D'), FPS, frame.size());
\r
888 startTimer(); next();
\r
889 writer.write(frame);
\r
895 //////////////////////////////////////////////////////
\r
898 PERF_TEST_P(Video, Video_VideoReader, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"))
\r
902 string inputFile = perf::TestBase::getDataPath(GetParam());
\r
906 cv::gpu::VideoReader_GPU d_reader(inputFile);
\r
907 ASSERT_TRUE( d_reader.isOpened() );
\r
909 cv::gpu::GpuMat d_frame;
\r
911 d_reader.read(d_frame);
\r
915 d_reader.read(d_frame);
\r
920 cv::VideoCapture reader(inputFile);
\r
921 ASSERT_TRUE( reader.isOpened() );
\r