Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How can I convert vector<point2f> to vector<keypoint>?

I want to extract SIFT descriptor from my choosen points. How can I convert vector<point2f> to vector<keypoint>? Here is my code segment. Image resolution is 256 by 256. Thanks in advance.

int main(...)
{
.......................
Mat image = imread("test0.png",CV_LOAD_IMAGE_GRAYSCALE);
std::vector<cv::Point2f> inputs;

inputs.push_back(cv::Point2f(0,0));
inputs.push_back(cv::Point2f(0,30));
inputs.push_back(cv::Point2f(0,90));
inputs.push_back(cv::Point2f(0,120));

vector<KeyPoint> keypoints;

// Here how can I convert vector<cv::Point2f> inputs to vector<KeyPoint> keypoints?


  //Similarly, we create a smart pointer to the SIFT extractor.
  Ptr<DescriptorExtractor> featureExtractor = DescriptorExtractor::create("SIFT");

  // Compute the 128 dimension SIFT descriptor at each keypoint.
  // Each row in "descriptors" correspond to the SIFT descriptor for each keypoint
  Mat descriptors;
  featureExtractor->compute(image, keypoints, descriptors);
.........................
}
click to hide/show revision 2
retagged

updated 2013-11-27 02:46:46 -0500

berak gravatar image

How can I convert vector<point2f> to vector<keypoint>?

I want to extract SIFT descriptor from my choosen points. How can I convert vector<point2f> to vector<keypoint>? Here is my code segment. Image resolution is 256 by 256. Thanks in advance.

int main(...)
{
.......................
Mat image = imread("test0.png",CV_LOAD_IMAGE_GRAYSCALE);
std::vector<cv::Point2f> inputs;

inputs.push_back(cv::Point2f(0,0));
inputs.push_back(cv::Point2f(0,30));
inputs.push_back(cv::Point2f(0,90));
inputs.push_back(cv::Point2f(0,120));

vector<KeyPoint> keypoints;

// Here how can I convert vector<cv::Point2f> inputs to vector<KeyPoint> keypoints?


  //Similarly, we create a smart pointer to the SIFT extractor.
  Ptr<DescriptorExtractor> featureExtractor = DescriptorExtractor::create("SIFT");

  // Compute the 128 dimension SIFT descriptor at each keypoint.
  // Each row in "descriptors" correspond to the SIFT descriptor for each keypoint
  Mat descriptors;
  featureExtractor->compute(image, keypoints, descriptors);
.........................
}