在我的OpenCV的項目,我想檢測的圖像複製僞造的舉動。我知道如何使用opencv FLANN在2個不同的圖像中進行特徵匹配,但是我對如何使用FLANN檢測圖像中的複製移動僞造變得非常困惑。如何使用OpenCV的特徵匹配檢測複製僞造移動
P.S1:我得到的篩關鍵點和形象的描述,並卡在使用特徵匹配類。
P.S2:特徵匹配的類型不是對我很重要。
在此先感謝。
更新:
這些圖片是什麼,我需要
一個例子,有一個相匹配兩幅圖像的特徵並做一些喜歡它的代碼兩個圖像(沒有一個),在機器人的OpenCV本地格式的代碼是象下面這樣:
vector<KeyPoint> keypoints;
Mat descriptors;
// Create a SIFT keypoint detector.
SiftFeatureDetector detector;
detector.detect(image_gray, keypoints);
LOGI("Detected %d Keypoints ...", (int) keypoints.size());
// Compute feature description.
detector.compute(image, keypoints, descriptors);
LOGI("Compute Feature ...");
FlannBasedMatcher matcher;
std::vector<DMatch> matches;
matcher.match(descriptors, descriptors, matches);
double max_dist = 0; double min_dist = 100;
//-- Quick calculation of max and min distances between keypoints
for(int i = 0; i < descriptors.rows; i++)
{ double dist = matches[i].distance;
if(dist < min_dist) min_dist = dist;
if(dist > max_dist) max_dist = dist;
}
printf("-- Max dist : %f \n", max_dist);
printf("-- Min dist : %f \n", min_dist);
//-- Draw only "good" matches (i.e. whose distance is less than 2*min_dist,
//-- or a small arbitary value (0.02) in the event that min_dist is very
//-- small)
//-- PS.- radiusMatch can also be used here.
std::vector<DMatch> good_matches;
for(int i = 0; i < descriptors.rows; i++)
{ if(matches[i].distance <= max(2*min_dist, 0.02))
{ good_matches.push_back(matches[i]); }
}
//-- Draw only "good" matches
Mat img_matches;
drawMatches(image, keypoints, image, keypoints,
good_matches, img_matches, Scalar::all(-1), Scalar::all(-1),
vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS);
//-- Show detected matches
// imshow("Good Matches", img_matches);
imwrite(imgOutFile, img_matches);
顯示你當前的代碼和您正在使用圖像的樣本肯定是有幫助的。 – alexisrozhkov
@ user3896254謝謝你的建議,我編輯自己的帖子,並添加例子和代碼 – Evil