Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

C:\fakepath\pso.png

I have been able to identify the exact images if they differ based on y co-ordinates. I'm unable to identify the image on the left.(All 3 images are same). Could you let me know the reason for this?

    MinMaxLocResult mmr = Core.minMaxLoc(resultMatrix);
    Mat bin = new Mat(toFindIn.rows() - toFind.rows() + 1, toFindIn.cols() - toFind.cols() + 1, CvType.CV_8UC1);
    double thresh = mmr.minVal * 1.05;
    resultMatrix.convertTo(resultMatrix, CvType.CV_8UC1, 255.0);
    Imgproc.threshold(resultMatrix, bin, thresh, 255.0, Imgproc.THRESH_BINARY_INV);

    MatOfPoint mop = new MatOfPoint();
    Mat idx = Mat.zeros(bin.size(), bin.channels());
    Core.findNonZero(bin, idx);
    mop = new MatOfPoint(idx);
    System.out.println(mop.dump());

Template Matching method used is Imgproc.TM_SQDIFF.

P.S: Read about template matching from the c++ tutorial you were mentioning :) @berak

click to hide/show revision 2
No.2 Revision

updated 2017-07-04 03:57:17 -0600

berak gravatar image

C:\fakepath\pso.pngC:\fakepath\pso.png

I have been able to identify the exact images if they differ based on y co-ordinates. I'm unable to identify the image on the left.(All 3 images are same). Could you let me know the reason for this?

    MinMaxLocResult mmr = Core.minMaxLoc(resultMatrix);
    Mat bin = new Mat(toFindIn.rows() - toFind.rows() + 1, toFindIn.cols() - toFind.cols() + 1, CvType.CV_8UC1);
    double thresh = mmr.minVal * 1.05;
    resultMatrix.convertTo(resultMatrix, CvType.CV_8UC1, 255.0);
    Imgproc.threshold(resultMatrix, bin, thresh, 255.0, Imgproc.THRESH_BINARY_INV);

    MatOfPoint mop = new MatOfPoint();
    Mat idx = Mat.zeros(bin.size(), bin.channels());
    Core.findNonZero(bin, idx);
    mop = new MatOfPoint(idx);
    System.out.println(mop.dump());

Template Matching method used is Imgproc.TM_SQDIFF.

P.S: Read about template matching from the c++ tutorial you were mentioning :) @berak

C:\fakepath\pso.png

I have been able to identify the exact images if they differ based only on the y co-ordinates. I'm unable to identify the image on the left.(All 3 images are same). Could you let me know the reason for this?

    MinMaxLocResult mmr = Core.minMaxLoc(resultMatrix);
    Mat bin = new Mat(toFindIn.rows() - toFind.rows() + 1, toFindIn.cols() - toFind.cols() + 1, CvType.CV_8UC1);
    double thresh = mmr.minVal * 1.05;
    resultMatrix.convertTo(resultMatrix, CvType.CV_8UC1, 255.0);
    Imgproc.threshold(resultMatrix, bin, thresh, 255.0, Imgproc.THRESH_BINARY_INV);

    MatOfPoint mop = new MatOfPoint();
    Mat idx = Mat.zeros(bin.size(), bin.channels());
    Core.findNonZero(bin, idx);
    mop = new MatOfPoint(idx);
    System.out.println(mop.dump());

Template Matching method used is Imgproc.TM_SQDIFF.

P.S: Read about template matching from the c++ tutorial you were mentioning :) @berak