Ask Your Question
1

Color of Keypoint with floating coordinates

asked 2013-09-03 09:00:30 -0500

Shaochan gravatar image

updated 2013-09-03 10:03:34 -0500

There are some missunderstandings, so I changed the question:

The coordinates of a keypoint are saved with floating values.

KeyPoint(float x, float y, float _size, float _angle=-1, float _response=0, int _octave=0, int _class_id=-1)

So the coordinates do not exactly match with a certain pixel but is within one pixel. That's how I unterstand it. Maybe I missunderstood.

I detect features to get color information. When I have keypointBob he is somewhere in the image img. I can get the color value by calling: img.at<vec3b>( keypointBob.pt)[]

Is OpenCv taking directly the color of the pixel (where the keypoint is within) or does OpenCv consider the neighbors?

I hope it's more clear now.

edit retag flag offensive close merge delete

Comments

Actually as far as I know keypoints in openCV's ML module are always extracted of the grayscale images and do not have any color information. So I am wondering where your question comes from.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-09-03 09:23:32 -0500 )edit
1

Only makes sense to me that he asks for a drawing function

Moster gravatar imageMoster ( 2013-09-03 09:29:04 -0500 )edit
1

Actually by adding this code, you are just indexing the intensity values of your original RGB image based on the keypoints returned location. The at operator however, rounds up your floating point coordinates to integer coordinates, which is needed for matrix indexing, resulting you the intensity value at that exact location.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-09-03 13:42:18 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-09-03 09:25:56 -0500

Moster gravatar image

updated 2013-09-03 09:27:03 -0500

You mean in the function cv::drawKeypoints? The color is random. 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 );
  }
}
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-09-03 09:00:30 -0500

Seen: 1,758 times

Last updated: Sep 03 '13