Ask Your Question
0

Imgproc.minEnclosingTriangle from Java [closed]

asked 2019-01-30 16:38:45 -0600

x54fd gravatar image

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.... How should I set up 'triangle' to make this work? Thanks in advance.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by x54fd
close date 2019-01-31 01:49:12.483559

1 answer

Sort by ยป oldest newest most voted
1

answered 2019-01-30 16:56:33 -0600

berak gravatar image

updated 2019-01-30 16:57:44 -0600

you don't need 2 cols in your points Mat, but 2 channels, like:

Mat points = Mat.zeros(4, 1, CvType.CV_32FC2);      
points.put(0, 0, 0,0);
points.put(1, 0, 1,0);
points.put(2, 0, 0,1);
points.put(3, 0, 1,1);    
Mat triangle = new Mat();
Imgproc.minEnclosingTriangle(points, triangle);
edit flag offensive delete link more

Comments

1

Ah, I see. Thanks a lot!

x54fd gravatar imagex54fd ( 2019-01-31 00:07:38 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-01-30 16:38:45 -0600

Seen: 260 times

Last updated: Jan 30 '19