Skip to content

Commit be84634

Browse files
Hamdi Sahloulcv3d
authored andcommitted
Freak - convert to gray instead of throwing an error
Similar to other descriptors, if the input image is colored, covert it silently to gray-level rather than terminating the execution
1 parent 53e3426 commit be84634

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

modules/xfeatures2d/src/freak.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,13 @@ void FREAK_Impl::compute( InputArray _image, std::vector<KeyPoint>& keypoints, O
333333
((FREAK_Impl*)this)->buildPattern();
334334

335335
// Convert to gray if not already
336-
Mat grayImage = image;
337-
CV_Assert(grayImage.channels() == 1);
336+
Mat grayImage;
337+
if( image.channels() == 3 || image.channels() == 4 )
338+
cvtColor(image, grayImage, COLOR_BGR2GRAY);
339+
else {
340+
CV_Assert(image.channels() == 1);
341+
grayImage = image;
342+
}
338343

339344
// Use 32-bit integers if we won't overflow in the integral image
340345
if ((image.depth() == CV_8U || image.depth() == CV_8S) &&

0 commit comments

Comments
 (0)