OpenCV C vs C ++

I'm trying to use SURF, but I'm having trouble finding a way to do this in C. The documentation seems to have material for C ++ in terms.

I was able to detect the SURF function:

    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 );
    }

But I can not find the method that I need to compare the descriptors from two images. I found this code in C ++, but it's hard for me to translate it:

    // 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);

I would appreciate it if someone could lead me to a descriptor or even better, tell me where I can find OpenCV documentation only in C.

+3
source share
2 answers

This link may give you a hint. https://projects.developer.nokia.com/opencv/browser/opencv/opencv-2.3.1/samples/c/find_obj.cpp . Look in functionnaiveNearestNeighbor

0

thioldhack. . QT, V++ . K- . .

0

All Articles