-1
다른 이미지 (주/큰 이미지) 안에 이미지 (템플릿/하위 이미지)를 찾는 자동화 안드로이드 응용 프로그램을 만들려고합니다.openCV를 사용하여 안드로이드에서 이미지 템플릿 매칭
메뉴 이미지는 원 플러스 3T에서입니다. Whatsapp 아이콘 이미지는 motoG 3에서 제작되었습니다.
oneplus 3T에서 whatsapp 이미지를 찾으려고 시도했으나 성공적으로 찾았습니다.
그러나 다른 화면 크기의 다른 장치에서 일부 하위 이미지를 찾으려고 할 때 작동하지 않습니다.
누군가 도와 드릴 수 있습니까? 아래는 내가 사용하고있는 코드입니다.
class MatchingDemo {
public Mat run(Mat img, Mat templ, String outFile, int match_method) {
System.out.println("\nRunning Template Matching");
///Create the result matrix
int result_cols = img.cols() - templ.cols() + 1;
int result_rows = img.rows() - templ.rows() + 1;
Mat result = new Mat(result_rows, result_cols, CvType.CV_32FC1);
///Do the Matching and Normalize
Imgproc.matchTemplate(img, templ, result, match_method);
Core.normalize(result, result, 0, 1, Core.NORM_MINMAX, -1, new Mat());
///Localizing the best match with minMaxLoc
MinMaxLocResult mmr = Core.minMaxLoc(result);
Point matchLoc;
if (match_method == Imgproc.TM_SQDIFF || match_method == Imgproc.TM_SQDIFF_NORMED) {
matchLoc = mmr.minLoc;
} else {
matchLoc = mmr.maxLoc;
}
System.out.println("matchloc.x "+ matchLoc.x);
System.out.println("templ.cols "+ templ.cols());
System.out.println("matchloc.y "+ matchLoc.y);
System.out.println("templ.rows "+ templ.rows());
///Show me what you got
Imgproc.rectangle(img, matchLoc, new Point(matchLoc.x + templ.cols(),
matchLoc.y + templ.rows()), new Scalar(0, 255, 0), 20);
// Save the visualized detection.
System.out.println("Writing "+ outFile);
Imgcodecs.imwrite(outFile, img);
return img;
}
}
으로 시도 할 수 있습니다 더 규모 불변 결과를 얻을 수 있는가? 또한 다양한 장치에서 글꼴이 달라질 수 있으므로 템플릿 이미지에서 * WhatsApp * 텍스트를 제거하면 템플릿 일치가 더 정확 해집니다. – ZdaR
안녕하세요 @ ZdaR .. 이미지 검색을위한 코드를 포함하여 질문을 편집했습니다. –
템플릿 이미지에서 * WhatsApp * 텍스트를 제거하라는 제안을 시도해 보셨습니까? – ZdaR