Ask Your Question

beny2111's profile - activity

2020-10-28 04:25:23 -0600 received badge  Nice Question (source)
2017-09-21 12:40:45 -0600 received badge  Famous Question (source)
2016-11-10 03:05:30 -0600 received badge  Notable Question (source)
2016-05-16 09:55:30 -0600 received badge  Popular Question (source)
2015-06-26 06:34:32 -0600 received badge  Student (source)
2014-06-26 07:27:44 -0600 commented answer Template matching with mutiple templates

i'm very confuse in convert c++ to java language, i'm so newbie -_-

2014-06-25 17:12:18 -0600 commented answer Template matching with mutiple templates

i'm sorry, from where you can get Img_Scene_Bgr and Img_Template_Bgr are the reference and template image

2014-06-25 07:46:36 -0600 commented answer Template matching with mutiple templates

okeee, thank you very much. Now I have to figure out how to walk in android.

2014-06-25 07:03:37 -0600 commented answer Template matching with mutiple templates

sorry, can you explain the purpose of the following code: List_Template_Img.push_back (Img_Template_1); because I build it in eclipse android java language, thank you so much for your attention

2014-06-22 08:01:51 -0600 commented question Template matching with mutiple templates

I use the above code is a template that is img_template what I want is what if using a lot of templates, so I have a template that is img_template1, img_template2, etc. so what kind of code should I use thank you, sorry if my english bad

2014-06-22 05:26:18 -0600 received badge  Editor (source)
2014-06-22 05:25:04 -0600 asked a question Template matching with mutiple templates

hi all, I'm working on the android application template matching. I get a problem to compare one image with multiple templates. is there here that can help me in resolving the issue. I would appreciate if anyone can help me. thank you

I write the following code that I use

public void matching() {

    Mat img = Highgui.imread("/mnt/sdcard/img_eq/img_eq.jpg", CvType.CV_8SC3);

    Mat templ = Highgui.imread("/mnt/sdcard/img_template/img_template.jpg", CvType.CV_8SC3);

    //Create the result matrix
    int match_method = Imgproc.TM_SQDIFF_NORMED;
    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_8SC3);

     //Do the Matching and Normalize
    Imgproc.matchTemplate(img, templ, result, match_method);
    int type = Imgproc.THRESH_TOZERO;
    Imgproc.threshold(result, result, 0.8, 1., type);
    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;
    }

    // / Show me what you got
    Core.rectangle(img, matchLoc, new Point(matchLoc.x + templ.cols(),matchLoc.y + templ.rows()), new Scalar(255, 0, 0));

    // Save the visualized detection.
    Highgui.imwrite("/mnt/sdcard/img_result/img_result.jpg", img);

    Mat image = Highgui.imread("/mnt/sdcard/img_result/img_result.jpg");
    Mat android_image = Mat.zeros(image.cols(), image.rows(), CvType.CV_8SC3);

    Imgproc.cvtColor(image, android_image, Imgproc.COLOR_BGR2RGB);

    Bitmap bm = Bitmap.createBitmap(android_image.cols(),android_image.rows(), Bitmap.Config.ARGB_8888);
    Utils.matToBitmap(android_image, bm);

    ImageView iv = (ImageView) findViewById(R.id.image);
    iv.setImageBitmap(bm);

}