mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
fix test failure of PyrLKOpticalFlow.Mat
* remove race condition * upload _prevPts to OpenCL device explicitly before calling "sparse"
This commit is contained in:
@@ -814,7 +814,7 @@ namespace
|
||||
double minEigThreshold_ = 1e-4) :
|
||||
winSize(winSize_), maxLevel(maxLevel_), criteria(criteria_), flags(flags_), minEigThreshold(minEigThreshold_)
|
||||
#ifdef HAVE_OPENCL
|
||||
, iters(criteria_.maxCount), derivLambda(criteria_.epsilon), useInitialFlow(0 != (flags_ & OPTFLOW_LK_GET_MIN_EIGENVALS)), waveSize(0)
|
||||
, iters(criteria_.maxCount), derivLambda(criteria_.epsilon), useInitialFlow(0 != (flags_ & OPTFLOW_LK_GET_MIN_EIGENVALS))
|
||||
#endif
|
||||
{
|
||||
}
|
||||
@@ -856,8 +856,6 @@ namespace
|
||||
calcPatchSize();
|
||||
if (patch.x <= 0 || patch.x >= 6 || patch.y <= 0 || patch.y >= 6)
|
||||
return false;
|
||||
if (!initWaveSize())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -926,19 +924,6 @@ namespace
|
||||
int iters;
|
||||
double derivLambda;
|
||||
bool useInitialFlow;
|
||||
int waveSize;
|
||||
bool initWaveSize()
|
||||
{
|
||||
waveSize = 1;
|
||||
if (isDeviceCPU())
|
||||
return true;
|
||||
|
||||
ocl::Kernel kernel;
|
||||
if (!kernel.create("lkSparse", cv::ocl::video::pyrlk_oclsrc, ""))
|
||||
return false;
|
||||
waveSize = (int)kernel.preferedWorkGroupSizeMultiple();
|
||||
return true;
|
||||
}
|
||||
dim3 patch;
|
||||
void calcPatchSize()
|
||||
{
|
||||
@@ -977,8 +962,8 @@ namespace
|
||||
if (isDeviceCPU())
|
||||
build_options = " -D CPU";
|
||||
else
|
||||
build_options = cv::format("-D WAVE_SIZE=%d -D WSX=%d -D WSY=%d",
|
||||
waveSize, wsx, wsy);
|
||||
build_options = cv::format("-D WSX=%d -D WSY=%d",
|
||||
wsx, wsy);
|
||||
|
||||
ocl::Kernel kernel;
|
||||
if (!kernel.create("lkSparse", cv::ocl::video::pyrlk_oclsrc, build_options))
|
||||
@@ -1064,7 +1049,9 @@ namespace
|
||||
_status.create((int)npoints, 1, CV_8UC1);
|
||||
UMat umatNextPts = _nextPts.getUMat();
|
||||
UMat umatStatus = _status.getUMat();
|
||||
return sparse(_prevImg.getUMat(), _nextImg.getUMat(), _prevPts.getUMat(), umatNextPts, umatStatus, umatErr);
|
||||
UMat umatPrevPts;
|
||||
_prevPts.getMat().copyTo(umatPrevPts);
|
||||
return sparse(_prevImg.getUMat(), _nextImg.getUMat(), umatPrevPts, umatNextPts, umatStatus, umatErr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user