Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

Hi,

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);

CODE

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);