2011-07-17 4 views
3

SURF에 대한 프로젝트를 수행하고 있으며 지금까지 SURF 기능을 성공적으로 구현했으며 제대로 기능 평가를 수행했습니다. 하지만 DESCRIPTOR 평가하는 법을 모르겠습니다 ... 저는 C++/opencv svn을 사용하고 있습니다.SURF에 대한 디스크립터 opencv

Here 당신은 즉, 평가자를 사용하지만 난 내 코드에서 사용할 수있는 방법을 보여줍니다 (OpenCV의의 SVN에서 샘플 코드를 찾을 수 ...

내 코드 수 :

#include "cv.h" // include standard OpenCV headers, same as before 
#include "highgui.h" 
#include "ml.h" 
#include <stdio.h> 
#include <iostream> 
#include <opencv2/features2d/features2d.hpp> 
#include <opencv2/imgproc/imgproc.hpp> 
#include <opencv2/highgui/highgui.hpp> 
#include <vector> 
//#include "precomp.hpp" 


using namespace cv; // all the new API is put into "cv" namespace. Export its content 
using namespace std; 

using std::cout; 
using std::cerr; 
using std::endl; 
using std::vector; 

// enable/disable use of mixed API in the code below. 
#define DEMO_MIXED_API_USE 1 
void warpPerspectiveRand(const Mat& src, Mat& dst, Mat& H, RNG& rng) 
{ 
    H.create(3, 3, CV_32FC1); 
    H.at<float>(0,0) = rng.uniform(0.8f, 1.2f); 
    H.at<float>(0,1) = rng.uniform(-0.1f, 0.1f); 
    H.at<float>(0,2) = rng.uniform(-0.1f, 0.1f)*src.cols; 
    H.at<float>(1,0) = rng.uniform(-0.1f, 0.1f); 
    H.at<float>(1,1) = rng.uniform(0.8f, 1.2f); 
    H.at<float>(1,2) = rng.uniform(-0.1f, 0.1f)*src.rows; 
    H.at<float>(2,0) = rng.uniform(-1e-4f, 1e-4f); 
    H.at<float>(2,1) = rng.uniform(-1e-4f, 1e-4f); 
    H.at<float>(2,2) = rng.uniform(0.8f, 1.2f); 

    warpPerspective(src, dst, H, src.size()); 
} 




double match(const vector<KeyPoint>& /*kpts_train*/, const vector<KeyPoint>& /*kpts_query*/, DescriptorMatcher& matcher, 
      const Mat& train, const Mat& query, vector<DMatch>& matches) 
{ 

    double t = (double)getTickCount(); 
    matcher.match(query, train, matches); //Using features2d 
    return ((double)getTickCount() - t)/getTickFrequency(); 
} 


void simpleMatching(Ptr<DescriptorMatcher>& descriptorMatcher, 
        const Mat& descriptors1, const Mat& descriptors2, 
        vector<DMatch>& matches12); 

int main(int argc, char** argv) 
{ 

string im1_name, im2_name; 
    im1_name = "lena.jpg"; 
    im2_name = "lena.jpg"; 

Mat img1 = imread(im1_name, 1); 
Mat img2 = imread(im2_name, 1); 

RNG rng = theRNG(); 
Mat H12; 
warpPerspectiveRand(img1, img2, H12, rng); 




    SurfFeatureDetector detector(2000); 
    vector<KeyPoint> keypoints1, keypoints2; 
    detector.detect(img1, keypoints1); 
    detector.detect(img2, keypoints2); 


float repeatability; 
int correspCount; 
evaluateFeatureDetector(img1, img2, H12, &keypoints1, &keypoints2, repeatability, correspCount); 

cout << "repeatability = " << repeatability << endl; 
     cout << "correspCount = " << correspCount << endl; 

    // computing descriptors 
    SurfDescriptorExtractor extractor; 
    Mat descriptors1, descriptors2; 
    extractor.compute(img1, keypoints1, descriptors1); 
    extractor.compute(img2, keypoints2, descriptors2); 


    return 0; 
} 

그래서 내 질문 : 나는 여러 가지 방법으로 시도 (수행하는 방법에 있음) SURF에 대한 설명을 평가하지만 난 그렇게 할 수있는 방법 ..

당신에게

답변

0

사용 기술자 매트를 정말 고마워요 쉐어

cv::BruteForceMatcher< cv::L2<float> > matcher; 
std::vector<cv::DMatch> matches; 
matcher.match(descriptors1, descriptors2, matches); 

이것은 일치하는 벡터를 얻을 것입니다. DMatch에 대한 설명서를 살펴보십시오.

는 또한이 기능을 살펴 가지고

cv::drawMatches(image1, keypoints1, image2, keypoints2, matches, outimage); 
cv::imshow("foo", outimage); 
+0

내가 그 기능을 시도하고 성공적으로 나와 함께 일을, 내 관심사는 다음과 같이이다 : 나는 기능의 PTR GDM = 새로운 VectorDescriptorMatcher을 (구현있을 때 추출기, 정련기); extractor와 matcher를 제외하고 valuateGenericDescriptorMatcher (img1, img2, H12, keypoints1, keypoints2, 0, 0, curve, gdm) 인 다음 함수를 구현하기 위해이 두 개의 매개 변수가 필요합니다. 그럼 여기서 내가 잘못하고있는 어떤 생각이 있니? – Mario

+2

아니. 이 질문을 닫고 최소한의 예를 들어 새 질문을하는 것이 좋습니다. – Unapiedra