OpenCV Android- Using Imgproc.moments causes crash

asked 2016-01-24 13:38:41 -0500

mattzap gravatar image

updated 2016-01-24 20:35:22 -0500

In OpenCV 3.1, the Moments class is back in the Android SDK. Yay!!!

However, upon calling the Imgproc.moments function, any of the multiple declarations with either contours or masks as parameters, the app crashes. I am unable to find an error in logcat. I do not understand what's going wrong.

Is anyone else getting similar issues?

 cd.caploop();
 //Do image processing
    if (cd.getCon() != null) {
        telemetry.addData("area", "" + Imgproc.contourArea(cd.getCon()));
        Point center;
        //I want to store the centroid of the mask in the point 'center'
        //I also have access to the contour I want to use above
        //but however I try to compute the moments, I get a crash
        Moments m = Imgproc.moments(cd.getConn());
    } else
        telemetry.addData("area", "not detected");
}
edit retag flag offensive close merge delete

Comments

what do you actually feed into moments() ? an image ? this should be a contour.

berak gravatar imageberak ( 2016-01-24 20:31:51 -0500 )edit
1

In this case, the code I presented, I was trying contours but was getting the SAME error. I'll change it back to what I had. Doesn't fix anything though. -Updated

mattzap gravatar imagemattzap ( 2016-01-24 20:34:48 -0500 )edit
1

hmm, works fine on desktop here, with both moments(contour) and moments(binImg, true)

berak gravatar imageberak ( 2016-01-24 21:25:11 -0500 )edit

Could this be another issue with the android SDK? I know the last release was missing the moments class ENTIRELY.

mattzap gravatar imagemattzap ( 2016-01-24 22:05:30 -0500 )edit