[Java OpenCV] Fatal error in Imgproc.arcLength
I've been trying to recode the squares.cpp C++ example in Java, using OpenCV 2.4.6, and I'm stuck with an error I don't understand:
OpenCV Error: Assertion failed (curve.checkVector(2) >= 0 && (curve.depth() == CV_32F || curve.depth() == CV_32S)) in arcLength, file /local/XXXX/libs/opencv-2.4.6/modules/imgproc/src/contours.cpp, line 1886
But when I check my curve, I get:
curve.checkVector(2) = 4
curve toString output: Mat [ 4 * 1 * CV_32SC2, isCont=true, isSubmat=false, nativeObj=0x7ffca453be90, dataAddr=0x7ffca4588720 ]
So I should be able to pass the assertion, but I fail.
Is CV_32SC2 different from CV_32S?
"Is CV_32SC2 different from CV_32S?"
yes, CV_32SC2 has 2 channels, CV_32S has only 1
but your mat there has the type CV_32SC2 and the depth CV_32S
so, what did you feed in ?
Thanks for the answer berak ! My mat is a MatOfPoint2f, in which I copy a MatOfPoint:
MatOfPoint contours = (previous code)
MatOfPoint2f contours2f = new MatOfPoint2f();
contours.copyTo(contours2f);
How can I copy the data in a MatOfPoint in a MatOfPoint2f and still keep type and depth coeherent?