Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Imgproc.minEnclosingTriangle from Java

I'm using opencv-400.jar and I'm trying to call the method minEnclosingTriangle in the following way.

System.loadLibrary(Core.NATIVE_LIBRARY_NAME);      
Mat points = Mat.zeros(4, 2, CvType.CV_32F);      
points.put(1, 0, 1);
points.put(2, 1, 1);
points.put(3, 0, 1);
points.put(3, 1, 1);    
Mat triangle = Mat.zeros(3, 2, CvType.CV_32F);
Imgproc.minEnclosingTriangle(points, triangle);

This results in an error: (-215:Assertion failed) channels() == CV_MAT_CN(dtype) in function 'cv::Mat::copyTo'. Apparently it originates from here: https://github.com/opencv/opencv/blob/master/modules/imgproc/src/min_enclosing_triangle.cpp#L325. How should I set up 'triangle' to make this work? Thanks in advance.