- make sure we deal with a grayscale image
authorVincent Rabaud <no@email>
Thu, 2 Jun 2011 22:58:52 +0000 (22:58 +0000)
committerVincent Rabaud <no@email>
Thu, 2 Jun 2011 22:58:52 +0000 (22:58 +0000)
modules/features2d/src/orb.cpp

index c0f2858..7f35118 100644 (file)
@@ -545,12 +545,16 @@ void ORB::operator()(const cv::Mat &image, const cv::Mat &mask, std::vector<cv::
  * @param do_keypoints if true, the keypoints are computed, otherwise used as an input
  * @param do_descriptors if true, also computes the descriptors
  */
-void ORB::operator()(const cv::Mat &image, const cv::Mat &mask, std::vector<cv::KeyPoint> & keypoints_in_out,
+void ORB::operator()(const cv::Mat &image_in, const cv::Mat &mask, std::vector<cv::KeyPoint> & keypoints_in_out,
                      cv::Mat & descriptors, bool do_keypoints, bool do_descriptors)
 {
   if ((!do_keypoints) && (!do_descriptors))
     return;
 
+  cv::Mat image;
+  if (image_in.type() != CV_8UC1)
+    cvtColor(image_in, image, CV_BGR2GRAY);
+
   if (do_descriptors)
     descriptors.release();
 
@@ -716,9 +720,6 @@ void ORB::computeKeyPoints(const std::vector<cv::Mat>& image_pyramid, const std:
 void ORB::computeOrientation(const cv::Mat& image, const cv::Mat& integral_image, unsigned int scale,
                              std::vector<cv::KeyPoint>& keypoints) const
 {
-  // If using the integral image, some offsets will be pre-computed for speed
-  std::vector<int> horizontal_offsets(8 * half_patch_size_), vertical_offsets(8 * half_patch_size_);
-
   // Process each keypoint
   for (std::vector<cv::KeyPoint>::iterator keypoint = keypoints.begin(), keypoint_end = keypoints.end(); keypoint
       != keypoint_end; ++keypoint)