Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You mean in the function cv::drawKeypoints? The color is random

void drawKeypoints( const Mat& image, const std::vector<KeyPoint>& keypoints, Mat& outImage,
                const Scalar& _color, int flags )
{
  if( !(flags & DrawMatchesFlags::DRAW_OVER_OUTIMG) )
  {
      if( image.type() == CV_8UC3 )
      {
          image.copyTo( outImage );
      }
      else if( image.type() == CV_8UC1 )
      {
          cvtColor( image, outImage, COLOR_GRAY2BGR );
      }
      else
      {
          CV_Error( Error::StsBadArg, "Incorrect type of input image.\n" );
      }
  }

  RNG& rng=theRNG();
  bool isRandColor = _color == Scalar::all(-1);

  CV_Assert( !outImage.empty() );
  std::vector<KeyPoint>::const_iterator it = keypoints.begin(),
                                 end = keypoints.end();
  for( ; it != end; ++it )
  {
      Scalar color = isRandColor ? Scalar(rng(256), rng(256), rng(256)) : _color;
      _drawKeypoint( outImage, *it, color, flags );
  }
}

You mean in the function cv::drawKeypoints? The color is randomrandom. Otherwise there is no color for a keypoint.

void drawKeypoints( const Mat& image, const std::vector<KeyPoint>& keypoints, Mat& outImage,
                const Scalar& _color, int flags )
{
  if( !(flags & DrawMatchesFlags::DRAW_OVER_OUTIMG) )
  {
      if( image.type() == CV_8UC3 )
      {
          image.copyTo( outImage );
      }
      else if( image.type() == CV_8UC1 )
      {
          cvtColor( image, outImage, COLOR_GRAY2BGR );
      }
      else
      {
          CV_Error( Error::StsBadArg, "Incorrect type of input image.\n" );
      }
  }

  RNG& rng=theRNG();
  bool isRandColor = _color == Scalar::all(-1);

  CV_Assert( !outImage.empty() );
  std::vector<KeyPoint>::const_iterator it = keypoints.begin(),
                                 end = keypoints.end();
  for( ; it != end; ++it )
  {
      Scalar color = isRandColor ? Scalar(rng(256), rng(256), rng(256)) : _color;
      _drawKeypoint( outImage, *it, color, flags );
  }
}