我是計算機視覺的初學者。我目前正在開發一個項目,在iOS中使用matchTemplate來查找兩個圖像之間的匹配。我面臨的問題是找到一種方法來確定兩個圖像是否匹配儘管matchTemplate運行良好。我想到了採用結果矩陣的百分比,但我不知道如何也找不到方法,並且MinMaxLoc也沒有和我一起工作。 如果任何人都可以幫助我或給我一個想法,我真的很感激它,因爲我現在處於絕望的境地。 這裏是代碼: `如何獲得模板匹配代碼的結果?
UIImage * image1 = [UIImage imageNamed:@「1.png」]; UIImage * image2 = [UIImage imageNamed:@「Image002.png」];
// Convert UIImage* to cv::Mat
UIImageToMat(image1, MatImage1);
UIImageToMat(image2, MatImage2);
MatImage1.resize(100 , 180);
MatImage2.resize(100 , 180);
if (!MatImage1.empty())
{
// Convert the image to grayscale
//we can also use BGRA2GRAY : Blue , Green , Red and Alpha(Opacity)
cv::cvtColor(MatImage1, grayImage1, cv::COLOR_BGRA2GRAY);
cv::cvtColor(MatImage2, grayImage2, cv::COLOR_BGRA2GRAY);
}
/// Create the result matrix
int result_cols = grayImage1.cols ;
int result_rows = grayImage1.rows ;
result.create(result_cols, result_rows, CV_32FC1);
/// Do the Matching and Normalize
matchTemplate(grayImage1 , grayImage2 , result , CV_TM_SQDIFF_NORMED);
//Normalize
normalize(result, result, 0, 100, cv::NORM_MINMAX, -1);
//Threshold
cv::threshold(result , result , 30, 0, CV_THRESH_TOZERO);`