How to convert MatOfPoint to MatOfPoint2f in opencv java api

MatOfPoint2f differs from MatOfPoint only in the type of the elements (32-bit float and 32-bit int respectively). The viable option (though with a performance penalty) is to create MatOfPoint2f instance and set its elements (in a loop) to be equal to the elements of of the source MatOfPoint.

There are

 public void fromArray(Point... lp);
 public Point[] toArray();

methods in both of the classes.

So you can do just

 /// Source variable
 MatOfPoint SrcMtx;

 /// New variable
 MatOfPoint2f  NewMtx = new MatOfPoint2f( SrcMtx.toArray() );

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)