Path: blob/master/modules/video/perf/opencl/perf_optflow_pyrlk.cpp
16350 views
/*M///////////////////////////////////////////////////////////////////////////////////////1//2// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.3//4// By downloading, copying, installing or using the software you agree to this license.5// If you do not agree to this license, do not download, install,6// copy or use the software.7//8//9// License Agreement10// For Open Source Computer Vision Library11//12// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.13// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.14// Third party copyrights are property of their respective owners.15//16// @Authors17// Fangfang Bai, [email protected]18// Jin Ma, [email protected]19//20// Redistribution and use in source and binary forms, with or without modification,21// are permitted provided that the following conditions are met:22//23// * Redistribution's of source code must retain the above copyright notice,24// this list of conditions and the following disclaimer.25//26// * Redistribution's in binary form must reproduce the above copyright notice,27// this list of conditions and the following disclaimer in the documentation28// and/or other materials provided with the distribution.29//30// * The name of the copyright holders may not be used to endorse or promote products31// derived from this software without specific prior written permission.32//33// This software is provided by the copyright holders and contributors as is and34// any express or implied warranties, including, but not limited to, the implied35// warranties of merchantability and fitness for a particular purpose are disclaimed.36// In no event shall the Intel Corporation or contributors be liable for any direct,37// indirect, incidental, special, exemplary, or consequential damages38// (including, but not limited to, procurement of substitute goods or services;39// loss of use, data, or profits; or business interruption) however caused40// and on any theory of liability, whether in contract, strict liability,41// or tort (including negligence or otherwise) arising in any way out of42// the use of this software, even if advised of the possibility of such damage.43//44//M*/4546#include "../perf_precomp.hpp"47#include "opencv2/ts/ocl_perf.hpp"4849#ifdef HAVE_OPENCL5051namespace opencv_test {52namespace ocl {5354typedef tuple< int > PyrLKOpticalFlowParams;55typedef TestBaseWithParam<PyrLKOpticalFlowParams> PyrLKOpticalFlowFixture;5657OCL_PERF_TEST_P(PyrLKOpticalFlowFixture, PyrLKOpticalFlow,58::testing::Values(1000, 2000, 4000)59)60{61Mat frame0 = imread(getDataPath("gpu/opticalflow/rubberwhale1.png"), cv::IMREAD_GRAYSCALE);62ASSERT_FALSE(frame0.empty()) << "can't load rubberwhale1.png";6364Mat frame1 = imread(getDataPath("gpu/opticalflow/rubberwhale2.png"), cv::IMREAD_GRAYSCALE);65ASSERT_FALSE(frame1.empty()) << "can't load rubberwhale2.png";6667UMat uFrame0; frame0.copyTo(uFrame0);68UMat uFrame1; frame1.copyTo(uFrame1);6970const Size winSize = Size(21, 21);71const int maxLevel = 3;72const TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01);73const int flags = 0;74const float minEigThreshold = 1e-4f;75const double eps = 1.0;7677const PyrLKOpticalFlowParams params = GetParam();78const int pointsCount = get<0>(params);7980// SKIP unstable tests81#ifdef __linux__82if (cvtest::skipUnstableTests && ocl::useOpenCL())83{84if (ocl::Device::getDefault().isIntel())85throw ::perf::TestBase::PerfSkipTestException();86}87#endif8889vector<Point2f> pts;90goodFeaturesToTrack(frame0, pts, pointsCount, 0.01, 0.0);91Mat ptsMat(1, static_cast<int>(pts.size()), CV_32FC2, (void *)&pts[0]);9293declare.in(uFrame0, uFrame1, WARMUP_READ);94UMat uNextPts, uStatus, uErr;95OCL_TEST_CYCLE()96cv::calcOpticalFlowPyrLK(uFrame0, uFrame1, pts, uNextPts, uStatus, uErr, winSize, maxLevel, criteria, flags, minEigThreshold);9798SANITY_CHECK(uNextPts, eps);99}100101} } // namespace opencv_test::ocl102103#endif // HAVE_OPENCL104105106