opencv: imgproc.Moments missing in OpenCV 3.0 for Android
Transferred from http://code.opencv.org/issues/4404
|| Karim Virani on 2015-06-13 15:44
|| Priority: High
|| Affected: branch 'master' (3.0-dev)
|| Category: android
|| Tracker: Bug
|| Difficulty:
|| PR:
|| Platform: Any / Android
imgproc.Moments missing in OpenCV 3.0 for Android
imgproc.Moments seems to have disappeared in openCVLibrary300 for java.
Looking in Improc.java it says this:
// Return type 'Moments' is not supported, skipping the function
Same for huMoments
These were supported as of 2.4.11
In the 3.0 android distribution, the whole Moments.java file seems to be missing from the imgproc folder and bindings seem removed from Imgproc.java
This breaks a lot of working code.
History
Maksim Shabunin on 2015-06-15 12:25
- Target version changed from 3.0 to 3.1
- Assignee changed from Alexander Smorkalov to Maksim Shabunin
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 1
- Comments: 21 (2 by maintainers)
For who need it now. Add this into Imgproc.java
public static Moments contourMoments( MatOfPoint contour ) { Moments m = new Moments(); int lpt = contour.checkVector(2); boolean is_float = true;//(contour.depth() == CvType.CV_32F); Point[] ptsi = contour.toArray(); //PointF[] ptsf = contour.toArray();
PepperX,
Prior to the workaround, to get the moments, you’d call the regular moments method in Imgproc, namely
Imgproc.moment(Mat array);
That method doesn’t work. Whatisor’s workaround is the new methods he presents for Imgproc.
Imgproc.contourMoments(MapOfPoint contour);
I copied that into the version of Imgproc under the OpenCVLibrary310 module in my project, and used that with a MatOfPoint contour to get the moments.
Hope that helps,
tonyc
On Tue, Oct 25, 2016 at 1:42 AM, PepperX notifications@github.com wrote:
PepperX – I think you took the right steps. The Moments should all be calculated correctly using whatisor’s code.
Note that whatinor’s method has a slightly different name/signature than the existing one. Also, are you passing a valid contour (MatOfPoint) to the method? What do the moments look like in the resulting Moment object?
Thanks @whatisor ,but i still have a problem after add the public static on imgproc.java ,i don’t know what should i do after that , my syntax

Moments
still red ,someone can help me please ? hopefully someone can help me 😃 Thanks