Mat tmp2_resize = new Mat (new_width , new_height, CvType.CV_8UC3);
Imgproc.resize( tmp2, tmp2_resize, sz2);
int result_cols = rgba.cols() - tmp2_resize.cols() + 1;
int result_rows = rgba.rows() - tmp2_resize.rows() + 1;
Log.i("OpenCV", "result_cols : " + result_cols + "\n");
Log.i("OpenCV", "result_rows : " + result_rows + "\n");
Mat result = new Mat(result_rows, result_cols, CvType.CV_32FC1);
Imgproc.matchTemplate(rgba, tmp2_resize, result, Imgproc.TM_CCOEFF);
// / Localizing the best match with minMaxLoc
MinMaxLocResult mmr = Core.minMaxLoc(result);
Point matchLoc;
matchLoc = mmr.maxLoc;
Log.i("OpenCV", "matchLoc.x : " + matchLoc.x + "\n");
Log.i("OpenCV", "matchLoc.y : " + matchLoc.y + "\n");
Core.rectangle(rgba, matchLoc, new Point(matchLoc.x + tmp2_resize.cols(),
matchLoc.y + tmp2_resize.rows()), new Scalar(0, 255, 0));
沒有留言:
張貼留言