|
|
|
@ -305,6 +305,11 @@ int cv::ocl::SURF_OCL::descriptorSize() const |
|
|
|
|
return extended ? 128 : 64; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int cv::ocl::SURF_OCL::descriptorType() const |
|
|
|
|
{ |
|
|
|
|
return CV_32F; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void cv::ocl::SURF_OCL::uploadKeypoints(const vector<KeyPoint> &keypoints, oclMat &keypointsGPU) |
|
|
|
|
{ |
|
|
|
|
if (keypoints.empty()) |
|
|
|
@ -447,6 +452,81 @@ void cv::ocl::SURF_OCL::operator()(const oclMat &img, const oclMat &mask, vector |
|
|
|
|
downloadDescriptors(descriptorsGPU, descriptors); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cv::ocl::SURF_OCL::operator()(InputArray img, InputArray mask, |
|
|
|
|
CV_OUT vector<KeyPoint>& keypoints) const |
|
|
|
|
{ |
|
|
|
|
this->operator()(img, mask, keypoints, noArray(), false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void cv::ocl::SURF_OCL::operator()(InputArray img, InputArray mask, vector<KeyPoint> &keypoints, |
|
|
|
|
OutputArray descriptors, bool useProvidedKeypoints) const |
|
|
|
|
{ |
|
|
|
|
oclMat _img, _mask; |
|
|
|
|
if(img.kind() == _InputArray::OCL_MAT) |
|
|
|
|
_img = *(oclMat*)img.obj; |
|
|
|
|
else |
|
|
|
|
_img.upload(img.getMat()); |
|
|
|
|
if(_img.channels() != 1) |
|
|
|
|
{ |
|
|
|
|
oclMat temp; |
|
|
|
|
cvtColor(_img, temp, COLOR_BGR2GRAY); |
|
|
|
|
_img = temp; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if( !mask.empty() ) |
|
|
|
|
{ |
|
|
|
|
if(mask.kind() == _InputArray::OCL_MAT) |
|
|
|
|
_mask = *(oclMat*)mask.obj; |
|
|
|
|
else |
|
|
|
|
_mask.upload(mask.getMat()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
SURF_OCL_Invoker surf((SURF_OCL&)*this, _img, _mask); |
|
|
|
|
oclMat keypointsGPU; |
|
|
|
|
|
|
|
|
|
if (!useProvidedKeypoints || !upright) |
|
|
|
|
((SURF_OCL*)this)->uploadKeypoints(keypoints, keypointsGPU); |
|
|
|
|
|
|
|
|
|
if (!useProvidedKeypoints) |
|
|
|
|
surf.detectKeypoints(keypointsGPU); |
|
|
|
|
else if (!upright) |
|
|
|
|
surf.findOrientation(keypointsGPU); |
|
|
|
|
if(keypointsGPU.cols*keypointsGPU.rows != 0) |
|
|
|
|
((SURF_OCL*)this)->downloadKeypoints(keypointsGPU, keypoints); |
|
|
|
|
|
|
|
|
|
if( descriptors.needed() ) |
|
|
|
|
{ |
|
|
|
|
oclMat descriptorsGPU; |
|
|
|
|
surf.computeDescriptors(keypointsGPU, descriptorsGPU, descriptorSize()); |
|
|
|
|
Size sz = descriptorsGPU.size(); |
|
|
|
|
if( descriptors.kind() == _InputArray::STD_VECTOR ) |
|
|
|
|
{ |
|
|
|
|
CV_Assert(descriptors.type() == CV_32F); |
|
|
|
|
std::vector<float>* v = (std::vector<float>*)descriptors.obj; |
|
|
|
|
v->resize(sz.width*sz.height); |
|
|
|
|
Mat m(sz, CV_32F, &v->at(0)); |
|
|
|
|
descriptorsGPU.download(m); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
descriptors.create(sz, CV_32F); |
|
|
|
|
Mat m = descriptors.getMat(); |
|
|
|
|
descriptorsGPU.download(m); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void cv::ocl::SURF_OCL::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask) const |
|
|
|
|
{ |
|
|
|
|
(*this)(image, mask, keypoints, noArray(), false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void cv::ocl::SURF_OCL::computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors) const |
|
|
|
|
{ |
|
|
|
|
(*this)(image, Mat(), keypoints, descriptors, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void cv::ocl::SURF_OCL::releaseMemory() |
|
|
|
|
{ |
|
|
|
|
sum.release(); |
|
|
|
|