mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-21 06:11:09 +08:00
NVIDIA Optical Flow Integration in OpenCV
This commit is contained in:

committed by
Vishal Bhaskar Chiluka

parent
f0d30f2ccb
commit
5e0783e1e9
@@ -326,4 +326,57 @@ PERF_TEST_P(ImagePair, OpticalFlowDual_TVL1,
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// NvidiaOpticalFlow_1_0
|
||||
|
||||
PERF_TEST_P(ImagePair, NvidiaOpticalFlow_1_0,
|
||||
Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
|
||||
{
|
||||
declare.time(10);
|
||||
|
||||
const cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(frame0.empty());
|
||||
|
||||
const cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(frame1.empty());
|
||||
|
||||
const int width = frame0.size().width;
|
||||
const int height = frame0.size().height;
|
||||
const bool enableTemporalHints = false;
|
||||
const bool enableExternalHints = false;
|
||||
const bool enableCostBuffer = false;
|
||||
const int gpuid = 0;
|
||||
|
||||
if (PERF_RUN_CUDA())
|
||||
{
|
||||
const cv::cuda::GpuMat d_frame0(frame0);
|
||||
const cv::cuda::GpuMat d_frame1(frame1);
|
||||
cv::cuda::GpuMat d_flow;
|
||||
cv::Ptr<cv::cuda::NvidiaOpticalFlow_1_0> d_nvof;
|
||||
try
|
||||
{
|
||||
d_nvof = cv::cuda::NvidiaOpticalFlow_1_0::create(width, height,
|
||||
cv::cuda::NvidiaOpticalFlow_1_0::NVIDIA_OF_PERF_LEVEL::NV_OF_PERF_LEVEL_FAST,
|
||||
enableTemporalHints, enableExternalHints, enableCostBuffer, gpuid);
|
||||
}
|
||||
catch (const cv::Exception& e)
|
||||
{
|
||||
if(e.code == Error::StsBadFunc || e.code == Error::StsBadArg || e.code == Error::StsNullPtr)
|
||||
throw SkipTestException("Current configuration is not supported");
|
||||
throw;
|
||||
}
|
||||
|
||||
TEST_CYCLE() d_nvof->calc(d_frame0, d_frame1, d_flow);
|
||||
|
||||
cv::cuda::GpuMat flow[2];
|
||||
cv::cuda::split(d_flow, flow);
|
||||
|
||||
cv::cuda::GpuMat u = flow[0];
|
||||
cv::cuda::GpuMat v = flow[1];
|
||||
|
||||
CUDA_SANITY_CHECK(u, 1e-10);
|
||||
CUDA_SANITY_CHECK(v, 1e-10);
|
||||
}
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
Reference in New Issue
Block a user