Skip to content

Commit a5b5684

Browse files
hrnralalek
authored andcommitted
Merge pull request opencv#9330 from hrnr:akaze_ocl
[GSOC] Enable OCL for AKAZE (opencv#9330) * revert e0489cb - reenable OCL for AKAZE * deal with conversion internally in AKAZE * pass InputArray directly to AKAZE to allow distiguishing input Mat/UMat. deal with conversion there * ensure that keypoints orientations are always computed. prevents misuse of internal AKAZE class. * covert internal AKAZE functions to use InputArray/OutputArray * make internal functions private in AKAZE * split OCL and CPU paths in AKAZE * create 2 separate pyramids, 1 for OCL and 1 for CPU * template functions that use temporaries to always store them as correct type (UMat/Mat) * remove variable used only in OCL path causes unused variable warning * update AKAZE documentation * run ocl version only when ocl is enabled * add tests for OCL path in AKAZE * relax condition for keypoints angle
1 parent 3a8dbeb commit a5b5684

File tree

5 files changed

+346
-180
lines changed

5 files changed

+346
-180
lines changed

modules/features2d/include/opencv2/features2d.hpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -658,13 +658,22 @@ class CV_EXPORTS_W KAZE : public Feature2D
658658
CV_WRAP virtual int getDiffusivity() const = 0;
659659
};
660660

661-
/** @brief Class implementing the AKAZE keypoint detector and descriptor extractor, described in @cite ANB13 . :
661+
/** @brief Class implementing the AKAZE keypoint detector and descriptor extractor, described in @cite ANB13.
662662
663-
@note AKAZE descriptors can only be used with KAZE or AKAZE keypoints. Try to avoid using *extract*
664-
and *detect* instead of *operator()* due to performance reasons. .. [ANB13] Fast Explicit Diffusion
665-
for Accelerated Features in Nonlinear Scale Spaces. Pablo F. Alcantarilla, Jesús Nuevo and Adrien
666-
Bartoli. In British Machine Vision Conference (BMVC), Bristol, UK, September 2013.
667-
*/
663+
@details AKAZE descriptors can only be used with KAZE or AKAZE keypoints. This class is thread-safe.
664+
665+
@note When you need descriptors use Feature2D::detectAndCompute, which
666+
provides better performance. When using Feature2D::detect followed by
667+
Feature2D::compute scale space pyramid is computed twice.
668+
669+
@note AKAZE implements T-API. When image is passed as UMat some parts of the algorithm
670+
will use OpenCL.
671+
672+
@note [ANB13] Fast Explicit Diffusion for Accelerated Features in Nonlinear
673+
Scale Spaces. Pablo F. Alcantarilla, Jesús Nuevo and Adrien Bartoli. In
674+
British Machine Vision Conference (BMVC), Bristol, UK, September 2013.
675+
676+
*/
668677
class CV_EXPORTS_W AKAZE : public Feature2D
669678
{
670679
public:

modules/features2d/src/akaze.cpp

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -169,46 +169,33 @@ namespace cv
169169
{
170170
CV_INSTRUMENT_REGION()
171171

172-
Mat img = image.getMat();
173-
if (img.channels() > 1)
174-
cvtColor(image, img, COLOR_BGR2GRAY);
175-
176-
Mat img1_32;
177-
if ( img.depth() == CV_32F )
178-
img1_32 = img;
179-
else if ( img.depth() == CV_8U )
180-
img.convertTo(img1_32, CV_32F, 1.0 / 255.0, 0);
181-
else if ( img.depth() == CV_16U )
182-
img.convertTo(img1_32, CV_32F, 1.0 / 65535.0, 0);
183-
184-
CV_Assert( ! img1_32.empty() );
172+
CV_Assert( ! image.empty() );
185173

186174
AKAZEOptions options;
187175
options.descriptor = descriptor;
188176
options.descriptor_channels = descriptor_channels;
189177
options.descriptor_size = descriptor_size;
190-
options.img_width = img.cols;
191-
options.img_height = img.rows;
178+
options.img_width = image.cols();
179+
options.img_height = image.rows();
192180
options.dthreshold = threshold;
193181
options.omax = octaves;
194182
options.nsublevels = sublevels;
195183
options.diffusivity = diffusivity;
196184

197185
AKAZEFeatures impl(options);
198-
impl.Create_Nonlinear_Scale_Space(img1_32);
186+
impl.Create_Nonlinear_Scale_Space(image);
199187

200188
if (!useProvidedKeypoints)
201189
{
202190
impl.Feature_Detection(keypoints);
203-
impl.Compute_Keypoints_Orientation(keypoints);
204191
}
205192

206193
if (!mask.empty())
207194
{
208195
KeyPointsFilter::runByPixelsMask(keypoints, mask.getMat());
209196
}
210197

211-
if( descriptors.needed() )
198+
if(descriptors.needed())
212199
{
213200
impl.Compute_Descriptors(keypoints, descriptors);
214201

0 commit comments

Comments
 (0)