How convert List<Mat> to MatofPoint2f with api java for opencv

asked 2014-07-25 14:57:21 -0500

rafaoc gravatar image


I am programming with the opencv api for java. And I'm trying to use the function findHomography. Its input must to be a MatofPoint2f but I have a set of points like a List(Mat).

To convert the List(Mat) to Mat I try the code below.
But I get the error: "java.lang.IllegalArgumentException: Incompatible Mat" at line

MatOfPoint2f imagePoints2f_1 = new MatOfPoint2f(mat_aux);


imagePoints_1 and imagePoints_2 are List(Mat)

Mat mat_aux;

mat_aux = Converters.vector_Mat_to_Mat(imagePoints_1);
MatOfPoint2f imagePoints2f_1 = new MatOfPoint2f(mat_aux);

mat_aux = Converters.vector_Mat_to_Mat(imagePoints_2);
MatOfPoint2f imagePoints2f_2 = new MatOfPoint2f(mat_aux);   

H = Calib3d.findHomography(imagePoints2f_1,imagePoints2f_2, Calib3d.LMEDS, 0.0);
edit retag flag offensive close merge delete


you probably want to convert 1 item from your list<Mat> to a MatofPoint2f, not the whole list

berak gravatar imageberak ( 2014-07-25 15:41:41 -0500 )edit

@berak: Actually, I want to convert the whole list

rafaoc gravatar imagerafaoc ( 2014-07-25 16:03:58 -0500 )edit

I've the same problem. Kinda frustrating.

Raki gravatar imageRaki ( 2016-11-16 05:33:31 -0500 )edit