From 0baf0bdc244d75cc5f1788a3d1670172b95493ca Mon Sep 17 00:00:00 2001 From: berak Date: Thu, 12 Nov 2015 06:26:42 +0100 Subject: [PATCH] AKAZE: check channels instead of type in detectAndCompute add same CV_32F and CV_16U support for KAZE --- modules/features2d/src/akaze.cpp | 2 +- modules/features2d/src/kaze.cpp | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/features2d/src/akaze.cpp b/modules/features2d/src/akaze.cpp index 1b6e30e459..bfe91af7ac 100644 --- a/modules/features2d/src/akaze.cpp +++ b/modules/features2d/src/akaze.cpp @@ -168,7 +168,7 @@ namespace cv bool useProvidedKeypoints) { Mat img = image.getMat(); - if (img.type() != CV_8UC1) + if (img.channels() > 1) cvtColor(image, img, COLOR_BGR2GRAY); Mat img1_32; diff --git a/modules/features2d/src/kaze.cpp b/modules/features2d/src/kaze.cpp index 327b46ae26..017490752d 100644 --- a/modules/features2d/src/kaze.cpp +++ b/modules/features2d/src/kaze.cpp @@ -111,11 +111,18 @@ namespace cv bool useProvidedKeypoints) { cv::Mat img = image.getMat(); - if (img.type() != CV_8UC1) + if (img.channels() > 1) cvtColor(image, img, COLOR_BGR2GRAY); Mat img1_32; - img.convertTo(img1_32, CV_32F, 1.0 / 255.0, 0); + if ( img.depth() == CV_32F ) + img1_32 = img; + else if ( img.depth() == CV_8U ) + img.convertTo(img1_32, CV_32F, 1.0 / 255.0, 0); + else if ( img.depth() == CV_16U ) + img.convertTo(img1_32, CV_32F, 1.0 / 65535.0, 0); + + CV_Assert( ! img1_32.empty() ); KAZEOptions options; options.img_width = img.cols;