@@ -66,6 +66,7 @@ namespace
66
66
{
67
67
public:
68
68
FAST_Impl (int threshold, bool nonmaxSuppression, int max_npoints);
69
+ ~FAST_Impl ();
69
70
70
71
virtual void detect (InputArray _image, std::vector<KeyPoint>& keypoints, InputArray _mask);
71
72
virtual void detectAsync (InputArray _image, OutputArray _keypoints, InputArray _mask, Stream& stream);
@@ -95,6 +96,12 @@ namespace
95
96
FAST_Impl::FAST_Impl (int threshold, bool nonmaxSuppression, int max_npoints) :
96
97
threshold_ (threshold), nonmaxSuppression_(nonmaxSuppression), max_npoints_(max_npoints)
97
98
{
99
+ cudaSafeCall ( cudaMalloc (&d_counter, sizeof (unsigned int )) );
100
+ }
101
+
102
+ FAST_Impl::~FAST_Impl ()
103
+ {
104
+ cudaSafeCall ( cudaFree (d_counter) );
98
105
}
99
106
100
107
void FAST_Impl::detect (InputArray _image, std::vector<KeyPoint>& keypoints, InputArray _mask)
@@ -116,8 +123,6 @@ namespace
116
123
{
117
124
using namespace cv ::cuda::device::fast;
118
125
119
- cudaSafeCall ( cudaMalloc (&d_counter, sizeof (unsigned int )) );
120
-
121
126
const GpuMat img = _image.getGpuMat ();
122
127
const GpuMat mask = _mask.getGpuMat ();
123
128
@@ -141,7 +146,6 @@ namespace
141
146
if (count == 0 )
142
147
{
143
148
_keypoints.release ();
144
- cudaSafeCall ( cudaFree (d_counter) );
145
149
return ;
146
150
}
147
151
@@ -166,8 +170,6 @@ namespace
166
170
kpLoc.colRange (0 , count).copyTo (locRow, stream);
167
171
keypoints.row (1 ).setTo (Scalar::all (0 ), stream);
168
172
}
169
-
170
- cudaSafeCall ( cudaFree (d_counter) );
171
173
}
172
174
173
175
void FAST_Impl::convert (InputArray _gpu_keypoints, std::vector<KeyPoint>& keypoints)
0 commit comments