일종의 파노라마를 만들기 위해 일부 이미지를 결합하려고합니다. 저는 OpenCV를 사용하고 있습니다. 우선 할 일은 키포인트와 디스크립터를 일치시키는 것보다 먼저 검출하는 것입니다. http://opencv.itseez.com/doc/user_guide/ug_features2d.html 을하지만 디버그하는 동안 나는이 라인에 표준 : : bad_alloc 뿐이다 예외 상대를 얻을 : :이 자습서를 다음있어 그렇게하려면OpenCV Matcher - std :: bad_alloc 예외
matcher.match(descriptors1, descriptors2, matches);
누군가는 저를 도와 드릴까요? 자습서를 붙인 &을 잘라 냈으므로 편집 오류가 없습니다.
감사합니다. G
전체 코드 :
Mat img1 = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
Mat img2 = imread(argv[2], CV_LOAD_IMAGE_GRAYSCALE);
if(img1.empty() || img2.empty())
{
printf("Can't read one of the images\n");
return -1;
}
// detecting keypoints
SurfFeatureDetector detector(400);
vector<KeyPoint> keypoints1, keypoints2;
detector.detect(img1, keypoints1);
detector.detect(img2, keypoints2);
// computing descriptors
SurfDescriptorExtractor extractor;
Mat descriptors1, descriptors2;
extractor.compute(img1, keypoints1, descriptors1);
extractor.compute(img2, keypoints2, descriptors2);
// 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);
업데이트 :
이 코드를 실행하면, 내가 얻을 :
런타임 검사 실패 #을 2 - 'keypoints1'변수 주위의 스택이 손상되었습니다.
코드 :
#include "opencv\cv.h"
#include "opencv\highgui.h"
using namespace cv;
using namespace std;
int main()
{
Mat img1 = imread("Chessboard1.jpg", CV_LOAD_IMAGE_GRAYSCALE);
Mat img2 = imread("Chessboard3.jpg", CV_LOAD_IMAGE_GRAYSCALE);
if(img1.empty() || img2.empty())
{
printf("Can't read one of the images\n");
return -1;
}
FastFeatureDetector detector(50);
vector<KeyPoint> keypoints1;
detector.detect(img1, keypoints1);
return 0;
}
의 부족량. – ScarletAmaranth
그 코드 행에는 선언 된 방법에 대해 알지 못하는 몇 가지 변수가 나와 있습니다. 한 줄의 코드만으로는 도움이되지 않습니다. – karlphillip