问题
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