Fix compiler warnings. Add additional test case for UseInitFlow

pull/2134/head
vbystricky 11 years ago
parent 3b0fa68a97
commit 3762036b08
  1. 8
      modules/video/src/optflowgf.cpp
  2. 16
      modules/video/test/ocl/test_optflow_farneback.cpp

@ -714,8 +714,8 @@ public:
if (fastPyramids)
{
polynomialExpansionOcl(pyramid0_[k], polyN, R[0]);
polynomialExpansionOcl(pyramid1_[k], polyN, R[1]);
polynomialExpansionOcl(pyramid0_[k], R[0]);
polynomialExpansionOcl(pyramid1_[k], R[1]);
}
else
{
@ -736,7 +736,7 @@ public:
{
gaussianBlurOcl(frames_[i], smoothSize/2, blurredFrame[i]);
resize(blurredFrame[i], pyrLevel[i], Size(width, height), INTER_LINEAR);
polynomialExpansionOcl(pyrLevel[i], polyN, R[i]);
polynomialExpansionOcl(pyrLevel[i], R[i]);
}
}
@ -874,7 +874,7 @@ private:
idxArg = kernel.set(idxArg, (void *)NULL, smem_size);
return kernel.run(2, globalsize, localsize, false);
}
bool polynomialExpansionOcl(const UMat &src, int polyN, UMat &dst)
bool polynomialExpansionOcl(const UMat &src, UMat &dst)
{
#ifdef ANDROID
size_t localsize[2] = { 128, 1};

@ -56,9 +56,10 @@ namespace
IMPLEMENT_PARAM_CLASS(PyrScale, double)
IMPLEMENT_PARAM_CLASS(PolyN, int)
CV_FLAGS(FarnebackOptFlowFlags, 0, OPTFLOW_FARNEBACK_GAUSSIAN)
IMPLEMENT_PARAM_CLASS(UseInitFlow, bool)
}
PARAM_TEST_CASE(FarnebackOpticalFlow, PyrScale, PolyN, FarnebackOptFlowFlags)
PARAM_TEST_CASE(FarnebackOpticalFlow, PyrScale, PolyN, FarnebackOptFlowFlags, UseInitFlow)
{
int numLevels;
int winSize;
@ -66,6 +67,7 @@ PARAM_TEST_CASE(FarnebackOpticalFlow, PyrScale, PolyN, FarnebackOptFlowFlags)
double pyrScale;
int polyN;
int flags;
bool useInitFlow;
virtual void SetUp()
{
@ -75,10 +77,11 @@ PARAM_TEST_CASE(FarnebackOpticalFlow, PyrScale, PolyN, FarnebackOptFlowFlags)
pyrScale = GET_PARAM(0);
polyN = GET_PARAM(1);
flags = GET_PARAM(2);
useInitFlow = GET_PARAM(3);
}
};
OCL_TEST_P(FarnebackOpticalFlow, Accuracy)
OCL_TEST_P(FarnebackOpticalFlow, Mat)
{
cv::Mat frame0 = readImage("optflow/RubberWhale1.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(frame0.empty());
@ -89,6 +92,12 @@ OCL_TEST_P(FarnebackOpticalFlow, Accuracy)
double polySigma = polyN <= 5 ? 1.1 : 1.5;
cv::Mat flow; cv::UMat uflow;
if (useInitFlow)
{
OCL_ON(cv::calcOpticalFlowFarneback(frame0, frame1, uflow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags));
uflow.copyTo(flow);
flags |= cv::OPTFLOW_USE_INITIAL_FLOW;
}
OCL_OFF(cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags));
OCL_ON(cv::calcOpticalFlowFarneback(frame0, frame1, uflow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags));
@ -100,7 +109,8 @@ OCL_INSTANTIATE_TEST_CASE_P(Video, FarnebackOpticalFlow,
Combine(
Values(PyrScale(0.3), PyrScale(0.5), PyrScale(0.8)),
Values(PolyN(5), PolyN(7)),
Values(FarnebackOptFlowFlags(0), FarnebackOptFlowFlags(cv::OPTFLOW_FARNEBACK_GAUSSIAN))
Values(FarnebackOptFlowFlags(0), FarnebackOptFlowFlags(cv::OPTFLOW_FARNEBACK_GAUSSIAN)),
Values(UseInitFlow(false), UseInitFlow(true))
)
);

Loading…
Cancel
Save