Ask Your Question
0

OpenCV4Android Unsatisfied Linker Error Moments

asked 2016-06-30 13:27:27 -0500

SumeetB gravatar image

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!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-06-30 19:41:10 -0500

updated 2016-07-01 14:10:00 -0500

you could try

import org.opencv.imgproc.Moments; // you should have this line to use Moments
.
.    
.
Imgproc.findContours(temp, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
for (int idx = 0; idx < contours.size(); idx++)
{
    MatOfPoint contour = contours.get(idx);
    Moments moment = Imgproc.moments(contour);
    double area = moment.m00;
    System.out.print( area );
}

or if your main need is only to calculate area

for (int idx = 0; idx < contours.size(); idx++)
{
    MatOfPoint contour = contours.get(idx);
    double area = Imgproc.contourArea(contour);
    System.out.print( area );
}
edit flag offensive delete link more

Comments

Tried it. Program does not reach the print statement. Problem is with the line "Moments moment = Imgproc.moments(contour);"

SumeetB gravatar imageSumeetB ( 2016-07-01 12:15:28 -0500 )edit
1

i think your OpenCV version is a bit old. here is the addition PR of Moments.

sturkmen gravatar imagesturkmen ( 2016-07-01 13:05:48 -0500 )edit

ok. I am using opencv 3.1.0, but I will try re-downloading the latest version from github.

SumeetB gravatar imageSumeetB ( 2016-07-01 13:08:06 -0500 )edit

wait i checked again. it should be in OpenCV 3.1. are you sure your OpenCV version is 3.1. and be sure you have import org.opencv.imgproc.Moments;

sturkmen gravatar imagesturkmen ( 2016-07-01 13:09:24 -0500 )edit

Just checked the OpenCV Library manifest. I am using 3.1.0 and I have Moments imported.

SumeetB gravatar imageSumeetB ( 2016-07-01 13:24:32 -0500 )edit

no more comment about Moments problem. look edited answer.

sturkmen gravatar imagesturkmen ( 2016-07-01 14:12:41 -0500 )edit

My main need is to extract information from contours such as xy position and area. Is there also a way to get xy position without moments? Sorry I did not include that in my original post, I did not think it would be relevant.

Note: I hesitated moving away from moments because it easily gets this information in 3 lines of code. I submitted the issue to itseez github, so hopefully they can come up with a solution soon.

SumeetB gravatar imageSumeetB ( 2016-07-01 14:23:53 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-06-30 13:27:27 -0500

Seen: 382 times

Last updated: Jul 01 '16