2014-09-24 2 views
-1

iOS에서 OpenCV를 사용하여 개체를 검색하려고합니다. 나는 this code sample from the documentation을 사용하고 있습니다.OpenCV DescriptorExtractor가 공백을 반환합니다.

Mat src = imread("src.jpg"); 
Mat templ = imread("logo.jpg"); 

Mat src_gray; 
cvtColor(src, src_gray, CV_BGR2GRAY); 

Mat templ_gray; 
cvtColor(templ, templ_gray, CV_BGR2GRAY); 

int minHessian = 500; 

OrbFeatureDetector detector(minHessian); 

std::vector<KeyPoint> keypoints_1, keypoints_2; 

detector.detect(src_gray, keypoints_1); 
detector.detect(templ_gray, keypoints_2); 

OrbDescriptorExtractor extractor; 

Mat descriptors_1, descriptors_2; 

extractor.compute(src_gray, keypoints_1, descriptors_1); 
extractor.compute(templ_gray, keypoints_2, descriptors_2); 

문제는 descriptors_1 항상 빈 잎 라인 extractor.compute(src_gray, keypoints_1, descriptors_1);에 :

여기 내 코드입니다.

srctempl은 비어 있지 않습니다.

의견이 있으십니까?

감사

난 당신이 기능 탐지기와 기술자를 사용하려는 경우 당신은 그들이 작동하는 방법으로 자신을 알려야한다고 생각 모두의
+0

keypoints_1이 비어 있습니까? – Dennis

+0

예,'keypoints_1'은 비어 있습니다. – Eric

+0

그러면 설명자를 계산할 수 없으므로 descriptors_1이 비어 있습니다. – Dennis

답변

0

첫 번째. https://dsp.stackexchange.com/questions/10423/why-do-we-use-keypoint-descriptors

난 당신이 ORB 검출기/기술자 작품 (u는 정말 원한다면 어떻게 더 잘 알고해야한다고 생각 첫 번째 단계 후 : 이 항목을 볼 수 있습니다 '페넬로페'의 대답은 내가 할 수있는 것보다 더 나은 모든 것을 설명 '때 ORB 검출기에'minHessian '매개 변수를 설정하기 때문에 https://www.willowgarage.com/sites/default/files/orb_final.pdf

http://docs.opencv.org/modules/features2d/doc/feature_detection_and_description.html 내가 이런 말 : 매개 변수는이를 위해 등, 무엇)을 사용 유는 OpenCV의 문서와 ORB 용지를 확인하실 수 있습니다 minHessian '은 실제로 SURF 감지기의 매개 변수입니다.

어쨌든 코드의 문제는 아닙니다.

Mat src = imread("src.jpg", CV_LOAD_IMAGE_GRAYSCALE); 
Mat templ = imread("logo.jpg", CV_LOAD_IMAGE_GRAYSCALE); 

가 그런 다음 키포인트를 감지 :

detector.detect(src, keypoints_1); 
detector.detect(templ, keypoints_2); 

을 빈 keypoints_2하지 keypoints_1 경우 지금 확인 당신이 다음은 예제와 같이 UR 이미지를로드하려고합니다. 그들이 기술자 추출을 위해가는 경우에! 작동합니다

희망이 도움이

관련 문제