Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

android opencv template matching error

I found this code and when i run it a lot of errors occured.

package com.example.match;

import android.os.Bundle; import android.app.Activity; import android.view.Menu;

import org.opencv.core.Core; import org.opencv.core.Core.MinMaxLocResult; import org.opencv.core.CvType; import org.opencv.core.Mat; import org.opencv.core.Point; import org.opencv.core.Scalar; import org.opencv.highgui.Highgui; import org.opencv.imgproc.Imgproc;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    run("bmp1.bmp", "bmp2.bmp", "bmp3.bmp", Imgproc.TM_CCOEFF);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}




    public void run(String inFile, String templateFile, String outFile, int match_method) {
        System.out.println("\nRunning Template Matching");

        Mat img = Highgui.imread(inFile);
        Mat templ = Highgui.imread(templateFile);

        // / 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;
        }

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

        // Save the visualized detection.
        System.out.println("Writing "+ outFile);
        Highgui.imwrite(outFile, img);


}

}

android opencv template matching error

I found this code and when i run it a lot of errors occured.

image description

package com.example.match;

import android.os.Bundle; import android.app.Activity; import android.view.Menu;

import org.opencv.core.Core; import org.opencv.core.Core.MinMaxLocResult; import org.opencv.core.CvType; import org.opencv.core.Mat; import org.opencv.core.Point; import org.opencv.core.Scalar; import org.opencv.highgui.Highgui; import org.opencv.imgproc.Imgproc;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    run("bmp1.bmp", "bmp2.bmp", "bmp3.bmp", Imgproc.TM_CCOEFF);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}




    public void run(String inFile, String templateFile, String outFile, int match_method) {
        System.out.println("\nRunning Template Matching");

        Mat img = Highgui.imread(inFile);
        Mat templ = Highgui.imread(templateFile);

        // / 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;
        }

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

        // Save the visualized detection.
        System.out.println("Writing "+ outFile);
        Highgui.imwrite(outFile, img);


}

}

android opencv template matching error

I found this code and when i run it a lot of errors occured.

image description

04-02 17:04:42.614: D/PhoneWindow(9887): FMB installDecor mIsFloating : false 04-02 17:04:42.614: D/PhoneWindow(9887): FMB installDecor flags : 8454400 04-02 17:04:42.614: D/OpenCV/StaticHelper(9887): Trying to get library list 04-02 17:04:42.624: E/OpenCV/StaticHelper(9887): OpenCV error: Cannot load info library for OpenCV 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): Library list: "" 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): First attempt to load libs 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): Trying to init OpenCV libs 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): Trying to load library opencv_java3 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): Cannot load library "opencv_java3" 04-02 17:04:42.624: W/System.err(9887): java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.match-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libopencv_java3.so" 04-02 17:04:42.624: W/System.err(9887): at java.lang.Runtime.loadLibrary(Runtime.java:366) 04-02 17:04:42.624: W/System.err(9887): at java.lang.System.loadLibrary(System.java:989) 04-02 17:04:42.624: W/System.err(9887): at org.opencv.android.StaticHelper.loadLibrary(StaticHelper.java:64) 04-02 17:04:42.624: W/System.err(9887): at org.opencv.android.StaticHelper.initOpenCVLibs(StaticHelper.java:95) 04-02 17:04:42.624: W/System.err(9887): at org.opencv.android.StaticHelper.initOpenCV(StaticHelper.java:39) 04-02 17:04:42.624: W/System.err(9887): at org.opencv.android.OpenCVLoader.initDebug(OpenCVLoader.java:77) 04-02 17:04:42.624: W/System.err(9887): at com.example.match.MainActivity.onCreate(MainActivity.java:23) 04-02 17:04:42.624: W/System.err(9887): at android.app.Activity.performCreate(Activity.java:6374) 04-02 17:04:42.624: W/System.err(9887): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) 04-02 17:04:42.624: W/System.err(9887): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2752) 04-02 17:04:42.624: W/System.err(9887): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2873) 04-02 17:04:42.624: W/System.err(9887): at android.app.ActivityThread.access$900(ActivityThread.java:181) 04-02 17:04:42.624: W/System.err(9887): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482) 04-02 17:04:42.624: W/System.err(9887): at android.os.Handler.dispatchMessage(Handler.java:102) 04-02 17:04:42.624: W/System.err(9887): at android.os.Looper.loop(Looper.java:145) 04-02 17:04:42.624: W/System.err(9887): at android.app.ActivityThread.main(ActivityThread.java:6145) 04-02 17:04:42.624: W/System.err(9887): at java.lang.reflect.Method.invoke(Native Method) 04-02 17:04:42.624: W/System.err(9887): at java.lang.reflect.Method.invoke(Method.java:372) 04-02 17:04:42.624: W/System.err(9887): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) 04-02 17:04:42.624: W/System.err(9887): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): First attempt to load libs fails 04-02 17:04:42.624: I/System.out(9887): Running Template Matching 04-02 17:04:42.624: E/art(9887): No implementation found for long org.opencv.imgcodecs.Imgcodecs.imread_1(java.lang.String) (tried Java_org_opencv_imgcodecs_Imgcodecs_imread_11 and Java_org_opencv_imgcodecs_Imgcodecs_imread_11__Ljava_lang_String_2) 04-02 17:04:42.624: D/AndroidRuntime(9887): Shutting down VM 04-02 17:04:42.624: E/AndroidRuntime(9887): FATAL EXCEPTION: main 04-02 17:04:42.624: E/AndroidRuntime(9887): Process: com.example.match, PID: 9887 04-02 17:04:42.624: E/AndroidRuntime(9887): java.lang.UnsatisfiedLinkError: No implementation found for long org.opencv.imgcodecs.Imgcodecs.imread_1(java.lang.String) (tried Java_org_opencv_imgcodecs_Imgcodecs_imread_11 and Java_org_opencv_imgcodecs_Imgcodecs_imread_11__Ljava_lang_String_2) 04-02 17:04:42.624: E/AndroidRuntime(9887): at org.opencv.imgcodecs.Imgcodecs.imread_1(Native Method) 04-02 17:04:42.624: E/AndroidRuntime(9887): at org.opencv.imgcodecs.Imgcodecs.imread(Imgcodecs.java:102) 04-02 17:04:42.624: E/AndroidRuntime(9887): at com.example.match.MainActivity.run(MainActivity.java:43) 04-02 17:04:42.624: E/AndroidRuntime(9887): at com.example.match.MainActivity.onCreate(MainActivity.java:27) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.Activity.performCreate(Activity.java:6374) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2752) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2873) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.ActivityThread.access$900(ActivityThread.java:181) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.os.Handler.dispatchMessage(Handler.java:102) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.os.Looper.loop(Looper.java:145) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.ActivityThread.main(ActivityThread.java:6145) 04-02 17:04:42.624: E/AndroidRuntime(9887): at java.lang.reflect.Method.invoke(Native Method) 04-02 17:04:42.624: E/AndroidRuntime(9887): at java.lang.reflect.Method.invoke(Method.java:372) 04-02 17:04:42.624: E/AndroidRuntime(9887): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) 04-02 17:04:42.624: E/AndroidRuntime(9887): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) 04-02 17:04:48.284: E/art(9887): No implementation found for void org.opencv.core.Mat.n_delete(long) (tried Java_org_opencv_core_Mat_n_1delete and Java_org_opencv_core_Mat_n_1delete__J) 04-02 17:04:48.284: E/System(9887): Uncaught exception thrown by finalizer 04-02 17:04:48.284: E/System(9887): java.lang.UnsatisfiedLinkError: No implementation found for void org.opencv.core.Mat.n_delete(long) (tried Java_org_opencv_core_Mat_n_1delete and Java_org_opencv_core_Mat_n_1delete__J) 04-02 17:04:48.284: E/System(9887): at org.opencv.core.Mat.n_delete(Native Method) 04-02 17:04:48.284: E/System(9887): at org.opencv.core.Mat.finalize(Mat.java:911) 04-02 17:04:48.284: E/System(9887): at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:209) 04-02 17:04:48.284: E/System(9887): at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:192) 04-02 17:04:48.284: E/System(9887): at java.lang.Thread.run(Thread.java:818)

package com.example.match;

import android.os.Bundle; import android.app.Activity; import android.view.Menu;

import org.opencv.core.Core; import org.opencv.core.Core.MinMaxLocResult; import org.opencv.core.CvType; import org.opencv.core.Mat; import org.opencv.core.Point; import org.opencv.core.Scalar; import org.opencv.highgui.Highgui; import org.opencv.imgproc.Imgproc;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    run("bmp1.bmp", "bmp2.bmp", "bmp3.bmp", Imgproc.TM_CCOEFF);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}




    public void run(String inFile, String templateFile, String outFile, int match_method) {
        System.out.println("\nRunning Template Matching");

        Mat img = Highgui.imread(inFile);
        Mat templ = Highgui.imread(templateFile);

        // / 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;
        }

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

        // Save the visualized detection.
        System.out.println("Writing "+ outFile);
        Highgui.imwrite(outFile, img);


}

}

android opencv template matching error

I found this code and when i run it a lot of errors occured.

image description

04-02 17:04:42.614: D/PhoneWindow(9887): FMB installDecor mIsFloating : false 04-02 17:04:42.614: D/PhoneWindow(9887): FMB installDecor flags : 8454400 04-02 17:04:42.614: D/OpenCV/StaticHelper(9887): Trying to get library list 04-02 17:04:42.624: E/OpenCV/StaticHelper(9887): OpenCV error: Cannot load info library for OpenCV 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): Library list: "" 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): First attempt to load libs 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): Trying to init OpenCV libs 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): Trying to load library opencv_java3 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): Cannot load library "opencv_java3" 04-02 17:04:42.624: W/System.err(9887): java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.match-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libopencv_java3.so" 04-02 17:04:42.624: W/System.err(9887): at java.lang.Runtime.loadLibrary(Runtime.java:366) 04-02 17:04:42.624: W/System.err(9887): at java.lang.System.loadLibrary(System.java:989) 04-02 17:04:42.624: W/System.err(9887): at org.opencv.android.StaticHelper.loadLibrary(StaticHelper.java:64) 04-02 17:04:42.624: W/System.err(9887): at org.opencv.android.StaticHelper.initOpenCVLibs(StaticHelper.java:95) 04-02 17:04:42.624: W/System.err(9887): at org.opencv.android.StaticHelper.initOpenCV(StaticHelper.java:39) 04-02 17:04:42.624: W/System.err(9887): at org.opencv.android.OpenCVLoader.initDebug(OpenCVLoader.java:77) 04-02 17:04:42.624: W/System.err(9887): at com.example.match.MainActivity.onCreate(MainActivity.java:23) 04-02 17:04:42.624: W/System.err(9887): at android.app.Activity.performCreate(Activity.java:6374) 04-02 17:04:42.624: W/System.err(9887): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) 04-02 17:04:42.624: W/System.err(9887): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2752) 04-02 17:04:42.624: W/System.err(9887): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2873) 04-02 17:04:42.624: W/System.err(9887): at android.app.ActivityThread.access$900(ActivityThread.java:181) 04-02 17:04:42.624: W/System.err(9887): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482) 04-02 17:04:42.624: W/System.err(9887): at android.os.Handler.dispatchMessage(Handler.java:102) 04-02 17:04:42.624: W/System.err(9887): at android.os.Looper.loop(Looper.java:145) 04-02 17:04:42.624: W/System.err(9887): at android.app.ActivityThread.main(ActivityThread.java:6145) 04-02 17:04:42.624: W/System.err(9887): at java.lang.reflect.Method.invoke(Native Method) 04-02 17:04:42.624: W/System.err(9887): at java.lang.reflect.Method.invoke(Method.java:372) 04-02 17:04:42.624: W/System.err(9887): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) 04-02 17:04:42.624: W/System.err(9887): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): First attempt to load libs fails 04-02 17:04:42.624: I/System.out(9887): Running Template Matching 04-02 17:04:42.624: E/art(9887): No implementation found for long org.opencv.imgcodecs.Imgcodecs.imread_1(java.lang.String) (tried Java_org_opencv_imgcodecs_Imgcodecs_imread_11 and Java_org_opencv_imgcodecs_Imgcodecs_imread_11__Ljava_lang_String_2) 04-02 17:04:42.624: D/AndroidRuntime(9887): Shutting down VM 04-02 17:04:42.624: E/AndroidRuntime(9887): FATAL EXCEPTION: main 04-02 17:04:42.624: E/AndroidRuntime(9887): Process: com.example.match, PID: 9887 04-02 17:04:42.624: E/AndroidRuntime(9887): java.lang.UnsatisfiedLinkError: No implementation found for long org.opencv.imgcodecs.Imgcodecs.imread_1(java.lang.String) (tried Java_org_opencv_imgcodecs_Imgcodecs_imread_11 and Java_org_opencv_imgcodecs_Imgcodecs_imread_11__Ljava_lang_String_2) 04-02 17:04:42.624: E/AndroidRuntime(9887): at org.opencv.imgcodecs.Imgcodecs.imread_1(Native Method) 04-02 17:04:42.624: E/AndroidRuntime(9887): at org.opencv.imgcodecs.Imgcodecs.imread(Imgcodecs.java:102) 04-02 17:04:42.624: E/AndroidRuntime(9887): at com.example.match.MainActivity.run(MainActivity.java:43) 04-02 17:04:42.624: E/AndroidRuntime(9887): at com.example.match.MainActivity.onCreate(MainActivity.java:27) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.Activity.performCreate(Activity.java:6374) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2752) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2873) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.ActivityThread.access$900(ActivityThread.java:181) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.os.Handler.dispatchMessage(Handler.java:102) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.os.Looper.loop(Looper.java:145) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.ActivityThread.main(ActivityThread.java:6145) 04-02 17:04:42.624: E/AndroidRuntime(9887): at java.lang.reflect.Method.invoke(Native Method) 04-02 17:04:42.624: E/AndroidRuntime(9887): at java.lang.reflect.Method.invoke(Method.java:372) 04-02 17:04:42.624: E/AndroidRuntime(9887): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) 04-02 17:04:42.624: E/AndroidRuntime(9887): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) 04-02 17:04:48.284: E/art(9887): No implementation found for void org.opencv.core.Mat.n_delete(long) (tried Java_org_opencv_core_Mat_n_1delete and Java_org_opencv_core_Mat_n_1delete__J) 04-02 17:04:48.284: E/System(9887): Uncaught exception thrown by finalizer 04-02 17:04:48.284: E/System(9887): java.lang.UnsatisfiedLinkError: No implementation found for void org.opencv.core.Mat.n_delete(long) (tried Java_org_opencv_core_Mat_n_1delete and Java_org_opencv_core_Mat_n_1delete__J) 04-02 17:04:48.284: E/System(9887): at org.opencv.core.Mat.n_delete(Native Method) 04-02 17:04:48.284: E/System(9887): at org.opencv.core.Mat.finalize(Mat.java:911) 04-02 17:04:48.284: E/System(9887): at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:209) 04-02 17:04:48.284: E/System(9887): at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:192) 04-02 17:04:48.284: E/System(9887): at java.lang.Thread.run(Thread.java:818)

package com.example.match;

import android.os.Bundle; import android.app.Activity; import android.view.Menu;

import org.opencv.core.Core; import org.opencv.core.Core.MinMaxLocResult; import org.opencv.core.CvType; import org.opencv.core.Mat; import org.opencv.core.Point; import org.opencv.core.Scalar; import org.opencv.highgui.Highgui; import org.opencv.imgproc.Imgproc;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    run("bmp1.bmp", "bmp2.bmp", "bmp3.bmp", Imgproc.TM_CCOEFF);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}




    public void run(String inFile, String templateFile, String outFile, int match_method) {
        System.out.println("\nRunning Template Matching");

        Mat img = Highgui.imread(inFile);
        Mat templ = Highgui.imread(templateFile);

        // / 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;
        }

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

        // Save the visualized detection.
        System.out.println("Writing "+ outFile);
        Highgui.imwrite(outFile, img);


}

}

android opencv template matching error

I found this code and when i run it a lot of errors occured.

04-02 17:04:42.614: D/PhoneWindow(9887): FMB installDecor mIsFloating : false 04-02 17:04:42.614: D/PhoneWindow(9887): FMB installDecor flags : 8454400 04-02 17:04:42.614: D/OpenCV/StaticHelper(9887): Trying to get library list 04-02 17:04:42.624: E/OpenCV/StaticHelper(9887): OpenCV error: Cannot load info library for OpenCV 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): Library list: "" 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): First attempt to load libs 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): Trying to init OpenCV libs 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): Trying to load library opencv_java3 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): Cannot load library "opencv_java3" 04-02 17:04:42.624: W/System.err(9887): java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.match-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libopencv_java3.so" 04-02 17:04:42.624: W/System.err(9887): at java.lang.Runtime.loadLibrary(Runtime.java:366) 04-02 17:04:42.624: W/System.err(9887): at java.lang.System.loadLibrary(System.java:989) 04-02 17:04:42.624: W/System.err(9887): at org.opencv.android.StaticHelper.loadLibrary(StaticHelper.java:64) 04-02 17:04:42.624: W/System.err(9887): at org.opencv.android.StaticHelper.initOpenCVLibs(StaticHelper.java:95) 04-02 17:04:42.624: W/System.err(9887): at org.opencv.android.StaticHelper.initOpenCV(StaticHelper.java:39) 04-02 17:04:42.624: W/System.err(9887): at org.opencv.android.OpenCVLoader.initDebug(OpenCVLoader.java:77) 04-02 17:04:42.624: W/System.err(9887): at com.example.match.MainActivity.onCreate(MainActivity.java:23) 04-02 17:04:42.624: W/System.err(9887): at android.app.Activity.performCreate(Activity.java:6374) 04-02 17:04:42.624: W/System.err(9887): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) 04-02 17:04:42.624: W/System.err(9887): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2752) 04-02 17:04:42.624: W/System.err(9887): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2873) 04-02 17:04:42.624: W/System.err(9887): at android.app.ActivityThread.access$900(ActivityThread.java:181) 04-02 17:04:42.624: W/System.err(9887): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482) 04-02 17:04:42.624: W/System.err(9887): at android.os.Handler.dispatchMessage(Handler.java:102) 04-02 17:04:42.624: W/System.err(9887): at android.os.Looper.loop(Looper.java:145) 04-02 17:04:42.624: W/System.err(9887): at android.app.ActivityThread.main(ActivityThread.java:6145) 04-02 17:04:42.624: W/System.err(9887): at java.lang.reflect.Method.invoke(Native Method) 04-02 17:04:42.624: W/System.err(9887): at java.lang.reflect.Method.invoke(Method.java:372) 04-02 17:04:42.624: W/System.err(9887): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) 04-02 17:04:42.624: W/System.err(9887): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): First attempt to load libs fails 04-02 17:04:42.624: I/System.out(9887): Running Template Matching 04-02 17:04:42.624: E/art(9887): No implementation found for long org.opencv.imgcodecs.Imgcodecs.imread_1(java.lang.String) (tried Java_org_opencv_imgcodecs_Imgcodecs_imread_11 and Java_org_opencv_imgcodecs_Imgcodecs_imread_11__Ljava_lang_String_2) 04-02 17:04:42.624: D/AndroidRuntime(9887): Shutting down VM 04-02 17:04:42.624: E/AndroidRuntime(9887): FATAL EXCEPTION: main 04-02 17:04:42.624: E/AndroidRuntime(9887): Process: com.example.match, PID: 9887 04-02 17:04:42.624: E/AndroidRuntime(9887): java.lang.UnsatisfiedLinkError: No implementation found for long org.opencv.imgcodecs.Imgcodecs.imread_1(java.lang.String) (tried Java_org_opencv_imgcodecs_Imgcodecs_imread_11 and Java_org_opencv_imgcodecs_Imgcodecs_imread_11__Ljava_lang_String_2) 04-02 17:04:42.624: E/AndroidRuntime(9887): at org.opencv.imgcodecs.Imgcodecs.imread_1(Native Method) 04-02 17:04:42.624: E/AndroidRuntime(9887): at org.opencv.imgcodecs.Imgcodecs.imread(Imgcodecs.java:102) 04-02 17:04:42.624: E/AndroidRuntime(9887): at com.example.match.MainActivity.run(MainActivity.java:43) 04-02 17:04:42.624: E/AndroidRuntime(9887): at com.example.match.MainActivity.onCreate(MainActivity.java:27) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.Activity.performCreate(Activity.java:6374) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2752) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2873) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.ActivityThread.access$900(ActivityThread.java:181) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.os.Handler.dispatchMessage(Handler.java:102) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.os.Looper.loop(Looper.java:145) 04-02 17:04:42.624: E/AndroidRuntime(9887): at android.app.ActivityThread.main(ActivityThread.java:6145) 04-02 17:04:42.624: E/AndroidRuntime(9887): at java.lang.reflect.Method.invoke(Native Method) 04-02 17:04:42.624: E/AndroidRuntime(9887): at java.lang.reflect.Method.invoke(Method.java:372) 04-02 17:04:42.624: E/AndroidRuntime(9887): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) 04-02 17:04:42.624: E/AndroidRuntime(9887): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) 04-02 17:04:48.284: E/art(9887): No implementation found for void org.opencv.core.Mat.n_delete(long) (tried Java_org_opencv_core_Mat_n_1delete and Java_org_opencv_core_Mat_n_1delete__J) 04-02 17:04:48.284: E/System(9887): Uncaught exception thrown by finalizer 04-02 17:04:48.284: E/System(9887): java.lang.UnsatisfiedLinkError: No implementation found for void org.opencv.core.Mat.n_delete(long) (tried Java_org_opencv_core_Mat_n_1delete and Java_org_opencv_core_Mat_n_1delete__J) 04-02 17:04:48.284: E/System(9887): at org.opencv.core.Mat.n_delete(Native Method) 04-02 17:04:48.284: E/System(9887): at org.opencv.core.Mat.finalize(Mat.java:911) 04-02 17:04:48.284: E/System(9887): at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:209) 04-02 17:04:48.284: E/System(9887): at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:192) 04-02 17:04:48.284: E/System(9887): at java.lang.Thread.run(Thread.java:818)

 public class MainActivity extends Activity {

{    
 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    run("bmp1.bmp", "bmp2.bmp", "bmp3.bmp", Imgproc.TM_CCOEFF);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}




    public void run(String inFile, String templateFile, String outFile, int match_method) {
        System.out.println("\nRunning Template Matching");

        Mat img = Highgui.imread(inFile);
        Mat templ = Highgui.imread(templateFile);

        // / 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;
        }

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

        // Save the visualized detection.
        System.out.println("Writing "+ outFile);
        Highgui.imwrite(outFile, img);


}

}