No implementation found for long org.opencv.core.Mat.n_Mat() error Using OpenCV

后端 未结 6 2014
闹比i
闹比i 2020-12-13 17:35

I am using OpenCV for adaptiveThreshold. My code for image processing using OpenCV is like this:

imageMat=new Mat();
Utils.bitmapToMat(bmp, imag         


        
相关标签:
6条回答
  • 2020-12-13 17:54

    Use this to resolve error.

    public class MainActivity : Activity
        {
    
            Mat m;
            Mat grayM;
            ImageView imageView;
            public MainActivity()
            {
                if (!OpenCVLoader.InitDebug())
                {
                    System.Console.WriteLine("GG");
                }
    
            }
    }
    
    0 讨论(0)
  • 2020-12-13 18:06

    Initialize openCV library in your activity add this code before onCreate() method

    static {
        if (!OpenCVLoader.initDebug()) {
            // Handle initialization error
        }
    }
    

    add this lib in your project : https://github.com/hschott/Camdroid

    0 讨论(0)
  • 2020-12-13 18:10

    Maybe you are forgetting to include the openCV library.

    Include

    static { 
         System.loadLibrary("opencv_java");
    }
    

    for OpenCV version 3 you should instead add:

    static { 
         System.loadLibrary("opencv_java3");
    }
    

    Good Luck :)

    0 讨论(0)
  • 2020-12-13 18:12

    I have successfully eliminate the error and my app does not crash while executing this line imageMat=new Mat();

    The reason for the error is that Android calls the "onCreate" method before loading the OpenCV4Android library.So i have used Async Initialization of OpenCV using OpenCVManager. I have created BaseLoaderCallback before onCreate method. And inside that i have declared new Mat() like this:

    private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
        @Override
        public void onManagerConnected(int status) {
            switch (status) {
                case LoaderCallbackInterface.SUCCESS:
                {
                    Log.i("OpenCV", "OpenCV loaded successfully");
                    imageMat=new Mat();
                } break;
                default:
                {
                    super.onManagerConnected(status);
                } break;
            }
        }
    };
    

    Then in onResume() i have checked if OpenCV library have been loaded and initialized from within current application package or not. The codes are as follows:

    public void onResume()
    {
        super.onResume();
        if (!OpenCVLoader.initDebug()) {
            Log.d("OpenCV", "Internal OpenCV library not found. Using OpenCV Manager for initialization");
            OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, this, mLoaderCallback);
        } else {
            Log.d("OpenCV", "OpenCV library found inside package. Using it!");
            mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
        }
    }
    

    And my error is gone. My full updated java class is here.

    Reference links :

    1. Async Initialization of OpenCV on Android using OpenCVManager
    2. Tutorial1Activity.java
    0 讨论(0)
  • 2020-12-13 18:16

    I put this line on onCreate method and make sure openCvManager is installed. This worked fine for me.

    OpenCVLoader.initDebug();

    0 讨论(0)
  • 2020-12-13 18:16

    Anyone suffering from mentioned issue over openvc4 in android try this, and comment if it was helpful please.

    some renaming operation is required to make it work.

    0 讨论(0)
提交回复
热议问题