我正在尝试使用SURF,但我在C语言中找不到方法时遇到了问题。文档中似乎只有C++的东西。OpenCV C vs C++
我已经能够检测SURF特征:
IplImage *img = cvLoadImage("img5.jpg");
CvMat* image = cvCreateMat(img->height, img->width, CV_8UC1);
cvCvtColor(img, image, CV_BGR2GRAY);
// detecting keypoints
CvSeq *imageKeypoints = 0, *imageDescriptors = 0;
int i;
//Extract SURF points by initializing parameters
CvSURFParams params = cvSURFParams(1, 1);
cvExtractSURF(image, 0, &imageKeypoints, &imageDescriptors, storage, params);
printf("Image Descriptors: %d\n", imageDescriptors->total);
//draw the keypoints on the captured frame
for(i = 0; i < imageKeypoints->total; i++)
{
CvSURFPoint* r = (CvSURFPoint*)cvGetSeqElem(imageKeypoints, i);
CvPoint center;
int radius;
center.x = cvRound(r->pt.x);
center.y = cvRound(r->pt.y);
radius = cvRound(r->size*1.2/9.*2);
cvCircle(image, center, radius, CV_RGB(0,255,0), 1, 8, 0);
}
但我无法找到我需要的描述符比较2个图像的方法。我发现在C本++编写代码,但我有麻烦它翻译:
// matching descriptors
BruteForceMatcher<L2<float> > matcher;
vector<DMatch> matches;
matcher.match(descriptors1, descriptors2, matches);
// drawing the results
namedWindow("matches", 1);
Mat img_matches;
drawMatches(img1, keypoints1, img2, keypoints2, matches, img_matches);
imshow("matches", img_matches);
waitKey(0);
我将不胜感激,如果有人可以带我到一个描述符匹配,甚至更好,让我知道在哪里可以找到OpenCV的文档只有C。
虽然这在理论上可以回答的问题,[这将是优选的](http://meta.stackexchange.com/q/8259)以包括回答的主要部分在这里,并提供链路参考。这也将有助于您的答案仍然很好,即使您将收录的链接打破了。 – 2012-05-11 06:22:58