私はコンピューター ビジョンの初心者です。現在、iOS で matchTemplate を使用して 2 つの画像の一致を見つけるプロジェクトに取り組んでいます。私が直面している問題は、2 つの画像が一致しているかどうかを判断する方法を見つけることです。結果マトリックスのパーセンテージを取得することを考えましたが、方法がわかりませんでした。また、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);`