2015-01-14 2 views
4

템플릿 이미지에서 찾은 특징 지점을 비디오 피드에 표시된 것과 일치시키는 프로그램이 있습니다. 나는이 프로그램을 실행하면 나는 다음과 같은 오류가 점점 오전 : 나는 문제가 함께 할 것입니다 생각 읽은 바로는OpenCV - SURF 포인트와 일치하는 런타임 오류

drawMatches(img_1, templateKeypoints, frames, keypoints_1, good_matches, img_matches, cv::Scalar::all(-1), cv::Scalar::all(-1), std::vector<char>(), cv::DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS); 

:

OpenCV Error: Assertion failed (i1 >= 0 && i1 < static_cast<int>(keypoints1.size())) in drawMatches, file bin/opencv-2.4.7/modules/features2d/src/draw.cpp, line 207 
terminate called after throwing an instance of 'cv::Exception' 
    what(): bin/opencv-2.4.7/modules/features2d/src/draw.cpp:207: error: (-215) i1 >= 0 && i1 < static_cast<int>(keypoints1.size()) in function drawMatches 

Aborted 

을이 위에 언급 한 기능 drawMatches입니다 비디오에서 발견 된 특징 포인트가 템플릿 이미지의 특징 포인트와 일치하지 않으면 프로그램이 중단됩니다.

min_dist = 100;  
for(int i = 0; i < img_descriptors_1.rows; i++) { 
     if(matches[i].distance <= 3 * min_dist) { 
      good_matches.push_back(matches[i]); 
     } 
     } 

일치하는 항목이 없어도 동영상을 계속해서 검색하고 싶습니다.

편집 : 그냥 다음 후

OpenCV Error: Assertion failed (npoints >= 0 && points2.checkVector(2) == npoints && points1.type() == points2.type()) in findHomography, file /home/colin/bin/opencv-2.4.7/modules/calib3d/src/fundam.cpp, line 1074 
terminate called after throwing an instance of 'cv::Exception' 
    what(): /home/colin/bin/opencv-2.4.7/modules/calib3d/src/fundam.cpp:1074: error: (-215) npoints >= 0 && points2.checkVector(2) == npoints && points1.type() == points2.type() in function findHomography 

Aborted 

답변

2

:

extractor.compute(img_1, keypoints_1, descriptors_1); 
extractor.compute(frame, keypoints_2, descriptors_2); 

하십시오 나는 반복적으로 가끔 다른 오류 메시지가 프로그램을 실행하려고하면 내가 눈치 챘을

추가 :

if ((descriptors_1.empty()) || (descriptors_2.empty())) 
continue; 

특정 프레임에 키포인트가 없으므로 다음 반복으로 이동하여 새 프레임을 확인해야합니다. 내 문제가 해결되었습니다.

+0

나는 이미 문제를 해결하고 같은 해결책을 찾았습니다. 나는 같은 문제를 가진 미래의 사람들에 대한 당신의 대답을 받아 들였습니다. – Colin747

관련 문제