2

두 개의 SIFT 설명자를 내가 생각할 수있는 가장 간단한 코드로 일치 시키려고 시도했지만 OpenCV 3은 예외를 계속 던지고 있습니다.두 개의 SIFT 설명자를 OpenCV와 일치시킬 수 없음

cv::Mat img1 = imread(...); // Shortened for the example 
cv::Mat img2 = imread(...); // Shortened for the example 

std::vector<KeyPoint> keypoints1, keypoints2; 
Ptr<SIFT> ptrSift = SIFT::create(200, 3, 0.07, 15); 
Mat descriptors1, descriptors2; 
ptrSift->detectAndCompute(img1, Mat(), keypoints1, descriptors1, false); 
ptrSift->detectAndCompute(img2, Mat(), keypoints2, descriptors2, false); 

위의 코드는 나에게 내가 drawKeypoints 기능을 시각화 할 수 있습니다 좋은 결과를 가져온다 :

내 코드입니다.

가 그럼 난 기술자에 맞게 다음 코드를 사용

BFMatcher matcher; 
std::vector<DMatch> matches; 
matcher.match(descriptors1, descriptors2, matches); 

을하지만 던지는 유지 :

C:\builds\master_PackSlave-win32-vc12-shared\opencv\modules\features2d\src\matchers.cpp:722: error: (-215) _queryDescriptors.type() == trainDescType in function cv::BFMatcher::knnMatchImpl

OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in cv::batchDistance, file C:\buil ds\master_PackSlave-win32-vc12-shared\opencv\modules\core\src\stat.cpp, line 3608 Exception: C:\builds\master_PackSlave-win32-vc12-shared\opencv\modules\core\src\stat.cpp:3608: error: (-215) type == src2.type() && src1.cols == src2. cols && (type == CV_32F || type == CV_8U) in function cv::batchDistance

감사

+0

http://robwhess.github.io/opensift/. 매우 빠르고 사용하기 쉽습니다. – qqibrow

+0

match() 호출 전에 descriptors1 또는 descriptors2가 비어 있는지 확인해야합니다. –

+0

의견을 보내 주셔서 감사합니다.하지만 비어 있지 않습니다. – Itay

답변

2

매우 흥미를 아래의 코드는 잘 나를 위해 작동 :

cv::BFMatcher matcher; 
std::vector<cv::DMatch> matches; 

cv::Mat descriptors1 = cv::Mat::eye(10, 10, CV_32F); 
cv::Mat descriptors2 = cv::Mat::eye(10, 10, CV_32F); 
matcher.match(descriptors1, descriptors2, matches); 

확인할 수 있습니까? 설명자의 크기와 유형을 제공 할 수 있습니까? 마지막으로 릴리스/디버그 모드에서 모두 시도해 보셨습니까?

주 : 버전을 사용하십니까? matshers.cpp를 최신 버전으로 덮어 쓰고 다시 컴파일해야합니다. https://github.com/Itseez/opencv/commits/master/modules/features2d/src/matchers.cpp

+0

글쎄요. 나는 행렬이 원래 질문에 대한 코멘트에서 전에 제안 된 누군가와 같이'CV_32F'가 아니라고 생각한다. 이제 'SiftDescriptorExtractor'에 문제가 있습니다 ... 코드가 구현되지 않았다면 ... 어쨌든 고마워요. – Itay