Search code examples
javaandroidopencvunsatisfiedlinkerror

Opencv4Android Unsatisfied Linker Error Moments


I am getting the following error when I try to run my android application:

java.lang.UnsatisfiedLinkError: No implementation found for double[] org.opencv.imgproc.Imgproc.moments_1(long) (tried Java_org_opencv_imgproc_Imgproc_moments_11 and Java_org_opencv_imgproc_Imgproc_moments_11__J)

Here is the code where the problem is occurring:

  Imgproc.findContours(temp, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);

    if(contours.size() > 0) {
        int numObjects = contours.size();

        if (numObjects < MAX_OBJECTS) {

            for (int i = 0; i < contours.size(); i++) {
                //moments causing unsatisfied linker error
                Moments moment = Imgproc.moments((Mat)contours.get(i));
                double area = moment.m00;
            }
        }
    }

Can anyone help me with this problem? Thanks in advance!


Solution

  • This seems to be an omission bug with some of the native libs for OpenCV 3.0 and 3.1. Until fixed, the suggested workaround is to use java code to calculate the moments. See this thread.