1 | initial version |
thanks, as you said The problem is that the matchTemplate() result is a float point single channel Mat
so I needed to normalize the mResult vector.
the solution is:
void TemplateMatch(){
mFind=new Mat(256, 192, CvType.CV_8UC4); Input = new Mat(256, 192, CvType.CV_8UC4);
Mat mResult8u = new Mat(256, 192, CvType.CV_8UC4);
mResult = new Mat(217, 153, CvType.CV_8UC4);
Utils.bitmapToMat(bmp2, mFind); Utils.bitmapToMat(bmp1, Input);
Imgproc.matchTemplate(mFind, Input, mResult, Imgproc.TM_SQDIFF) ;
bmp3= Bitmap.createBitmap(mResult.cols(), mResult.rows(),Bitmap.Config.ARGB_8888); Core.normalize(mResult, mResult8u, 0, 255, Core.NORM_MINMAX, CvType.CV_8U); Utils.matToBitmap(mResult8u, bmp3); iv2.setImageBitmap(bmp3);
}