Tôi có câu hỏi về các đối tượng khớp với OpenCV. Tôi đang sử dụng thuật toán SURF được triển khai trong opencv 2.3 để phát hiện các tính năng trên mỗi hình ảnh, sau đó trích xuất các mô tả về các tính năng này. Vấn đề trong kết hợp sử dụng Brute Force Matcher, tôi không biết làm thế nào tôi đánh giá rằng hai hình ảnh được khớp hoặc không giống như khi tôi đang sử dụng hai hình ảnh khác nhau có những dòng giữa các descriptors trong hai hình ảnh!OpenCV - Đối sánh đối tượng bằng cách sử dụng các mô tả SURF và BruteForceMatcher
Kết quả đầu ra của mã của tôi, hai hình ảnh -I so sánh với chúng - giống nhau hoặc khác nhau, hình ảnh kết quả cho biết rằng hai hình ảnh được khớp.
Câu hỏi đặt ra là: Làm cách nào để phân biệt giữa hai hình ảnh?
Đúng khớp:
False phù hợp !! :
Mã của tôi:
Mat image1, outImg1, image2, outImg2;
// vector of keypoints
vector<KeyPoint> keypoints1, keypoints2;
// Read input images
image1 = imread("C://Google-Logo.jpg",0);
image2 = imread("C://Alex_Eng.jpg",0);
SurfFeatureDetector surf(2500);
surf.detect(image1, keypoints1);
surf.detect(image2, keypoints2);
drawKeypoints(image1, keypoints1, outImg1, Scalar(255,255,255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
drawKeypoints(image2, keypoints2, outImg2, Scalar(255,255,255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
namedWindow("SURF detector img1");
imshow("SURF detector img1", outImg1);
namedWindow("SURF detector img2");
imshow("SURF detector img2", outImg2);
SurfDescriptorExtractor surfDesc;
Mat descriptors1, descriptors2;
surfDesc.compute(image1, keypoints1, descriptors1);
surfDesc.compute(image2, keypoints2, descriptors2);
BruteForceMatcher<L2<float>> matcher;
vector<DMatch> matches;
matcher.match(descriptors1,descriptors2, matches);
nth_element(matches.begin(), matches.begin()+24, matches.end());
matches.erase(matches.begin()+25, matches.end());
Mat imageMatches;
drawMatches(image1, keypoints1, image2, keypoints2, matches, imageMatches, Scalar(255,255,255));
namedWindow("Matched");
imshow("Matched", imageMatches);
cv::waitKey();
return 0;
Cuốn sách này hóa ra khá hữu ích! –
Bạn nên chấp nhận câu trả lời của mình. –