Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions modules/cudafeatures2d/src/fast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ namespace
{
public:
FAST_Impl(int threshold, bool nonmaxSuppression, int max_npoints);
~FAST_Impl();

virtual void detect(InputArray _image, std::vector<KeyPoint>& keypoints, InputArray _mask);
virtual void detectAsync(InputArray _image, OutputArray _keypoints, InputArray _mask, Stream& stream);
Expand Down Expand Up @@ -95,6 +96,12 @@ namespace
FAST_Impl::FAST_Impl(int threshold, bool nonmaxSuppression, int max_npoints) :
threshold_(threshold), nonmaxSuppression_(nonmaxSuppression), max_npoints_(max_npoints)
{
cudaSafeCall( cudaMalloc(&d_counter, sizeof(unsigned int)) );
}

FAST_Impl::~FAST_Impl()
{
cudaSafeCall( cudaFree(d_counter) );
}

void FAST_Impl::detect(InputArray _image, std::vector<KeyPoint>& keypoints, InputArray _mask)
Expand All @@ -116,8 +123,6 @@ namespace
{
using namespace cv::cuda::device::fast;

cudaSafeCall( cudaMalloc(&d_counter, sizeof(unsigned int)) );

const GpuMat img = _image.getGpuMat();
const GpuMat mask = _mask.getGpuMat();

Expand Down Expand Up @@ -165,8 +170,6 @@ namespace
kpLoc.colRange(0, count).copyTo(locRow, stream);
keypoints.row(1).setTo(Scalar::all(0), stream);
}

cudaSafeCall( cudaFree(d_counter) );
}

void FAST_Impl::convert(InputArray _gpu_keypoints, std::vector<KeyPoint>& keypoints)
Expand Down
Loading