How to find descriptors for manualy defined landmarks with opencv

核能气质少年 提交于 2019-12-12 04:49:09

问题


I am trying to generate "SIFT" descriptor (SIFT is only an example) for some manualy defined landmarks. When I try to do:

siftDetector(grayImage, Mat(), manualLandmarks, descriptors, true);

the result is always 0 (zero) for the descriptors. I have described manualLandmarks as std::vector<cv::KeyPoint>, and I have changed the x and y coordinates for each item in the vector (the size, octave and angle values are not changed).

Is there a way to define manualy the image coordinates and compute the descriptors for that location?

Thanks.


回答1:


cv::Mat I = imread("image.jpg"); // load the image


std::vector<cv::Point2f> inputs;

inputs.push_back(cv::Point(74,114)); // manually defined landmark
inputs.push_back(cv::Point(130,114)); // manually defined landmark 

std::vector<cv::KeyPoint> kp;
for( size_t i = 0; i < inputs.size(); i++ ) {
kp.push_back(cv::KeyPoint(inputs[i], 1.f));
}

cv::Mat descriptors;
cv::SiftFeatureDetector detector;
detector.compute(I, kp, descriptors); // descriptors are the sift descriptors on manually defined landmarks


来源:https://stackoverflow.com/questions/25744075/how-to-find-descriptors-for-manualy-defined-landmarks-with-opencv

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!