Fix a bug of gfft.
authorpeng xiao <hisenxpress@gmail.com>
Tue, 4 Jun 2013 07:55:33 +0000 (15:55 +0800)
committerpeng xiao <hisenxpress@gmail.com>
Tue, 4 Jun 2013 07:55:33 +0000 (15:55 +0800)
When user provided corners buffer is big enough to be copied to from
tmpCorners_, we allow the buffer to be reused other than allocate a new
cl_mem object.

modules/ocl/src/gfft.cpp
modules/ocl/test/test_optflow.cpp

index af7580b..7fd5e3a 100644 (file)
@@ -257,7 +257,8 @@ void cv::ocl::GoodFeaturesToTrackDetector_OCL::operator ()(const oclMat& image,
     
     if (minDistance < 1)
     {
-        corners = tmpCorners_(Rect(0, 0, maxCorners > 0 ? std::min(maxCorners, total) : total, 1));
+        Rect roi_range(0, 0, maxCorners > 0 ? std::min(maxCorners, total) : total, 1);
+        tmpCorners_(roi_range).copyTo(corners);
     }
     else
     {
index 0121be8..72689f3 100644 (file)
@@ -121,7 +121,7 @@ TEST_P(GoodFeaturesToTrack, EmptyCorners)
 
     cv::ocl::GoodFeaturesToTrackDetector_OCL detector(maxCorners, qualityLevel, minDistance);
 
-    cv::ocl::oclMat src(100, 100, CV_8UC1, cv::Scalar::all(0));
+    cv::ocl::oclMat src(100, 128, CV_8UC1, cv::Scalar::all(0));
     cv::ocl::oclMat corners(1, maxCorners, CV_32FC2);
 
     detector(src, corners);