@@ -55,7 +55,7 @@ namespace cv { namespace cuda { namespace device
55
55
{
56
56
namespace gfft
57
57
{
58
- int findCorners_gpu (const cudaTextureObject_t &eigTex_, const int &rows, const int &cols, float threshold, PtrStepSzb mask, float2* corners, int max_count, cudaStream_t stream);
58
+ int findCorners_gpu (const cudaTextureObject_t &eigTex_, const int &rows, const int &cols, float threshold, PtrStepSzb mask, float2* corners, int max_count, int * counterPtr, cudaStream_t stream);
59
59
void sortCorners_gpu (const cudaTextureObject_t &eigTex_, float2* corners, int count, cudaStream_t stream);
60
60
}
61
61
}}}
@@ -67,7 +67,7 @@ namespace
67
67
public:
68
68
GoodFeaturesToTrackDetector (int srcType, int maxCorners, double qualityLevel, double minDistance,
69
69
int blockSize, bool useHarrisDetector, double harrisK);
70
-
70
+ ~GoodFeaturesToTrackDetector ();
71
71
void detect (InputArray image, OutputArray corners, InputArray mask, Stream& stream);
72
72
73
73
private:
@@ -82,6 +82,8 @@ namespace
82
82
GpuMat buf_;
83
83
GpuMat eig_;
84
84
GpuMat tmpCorners_;
85
+
86
+ int * counterPtr_;
85
87
};
86
88
87
89
GoodFeaturesToTrackDetector::GoodFeaturesToTrackDetector (int srcType, int maxCorners, double qualityLevel, double minDistance,
@@ -93,6 +95,12 @@ namespace
93
95
cornerCriteria_ = useHarrisDetector ?
94
96
cuda::createHarrisCorner (srcType, blockSize, 3 , harrisK) :
95
97
cuda::createMinEigenValCorner (srcType, blockSize, 3 );
98
+ cudaSafeCall (cudaMalloc (&counterPtr_, sizeof (int )));
99
+ }
100
+
101
+ GoodFeaturesToTrackDetector::~GoodFeaturesToTrackDetector ()
102
+ {
103
+ cudaSafeCall (cudaFree (counterPtr_));
96
104
}
97
105
98
106
void GoodFeaturesToTrackDetector::detect (InputArray _image, OutputArray _corners, InputArray _mask, Stream& stream)
@@ -125,7 +133,7 @@ namespace
125
133
PtrStepSzf eig = eig_;
126
134
cv::cuda::device::createTextureObjectPitch2D<float >(&eigTex_, eig, texDesc);
127
135
128
- int total = findCorners_gpu (eigTex_, eig_.rows , eig_.cols , static_cast <float >(maxVal * qualityLevel_), mask, tmpCorners_.ptr <float2>(), tmpCorners_.cols , stream_);
136
+ int total = findCorners_gpu (eigTex_, eig_.rows , eig_.cols , static_cast <float >(maxVal * qualityLevel_), mask, tmpCorners_.ptr <float2>(), tmpCorners_.cols , counterPtr_, stream_);
129
137
130
138
131
139
if (total == 0 )
0 commit comments