3

SURF を使用しようとしていますが、C でその方法を見つけるのに問題があります。ドキュメントには、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);

誰かが私を記述子マッチャーに導くことができれば幸いです.CのみでOpenCVのドキュメントを見つけることができる場所を教えてください.

4

3 に答える 3

0

このリンクがヒントになるかもしれません。https://projects.developer.nokia.com/opencv/browser/opencv/opencv-2.3.1/samples/c/find_obj.cpp . 関数を見てくださいnaiveNearestNeighbor

于 2012-04-23T08:51:20.837 に答える
0

Thioldhackのブログ投稿をご覧ください。サンプルコードが含まれています。これは QT 用ですが、VC++ などでも簡単に実行できます。K 最近傍アルゴリズムを使用してキー ポイントを一致させる必要があります。それはすべてを持っています。

于 2012-04-23T11:18:05.497 に答える