Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

need a help on MatOfPoint2f

I am rewriting WarpAffine related code in Android. But I can hardly get how to use MatOfPoint2f.

My previous code is like: (using OpenCVSharp)

CvPoint2D32f[] src_pf = new CvPoint2D32f[3];
CvPoint2D32f[] dst_pf = new CvPoint2D32f[3];
src_pf[0] = new CvPoint2D32f(0,0);
src_pf[1] = new CvPoint2D32f(100,100);
src_pf[2] = new CvPoint2D32f(100,70);
dst_pf[0] = new CvPoint2D32f(0,0);
dst_pf[1] = new CvPoint2D32f(100,100);
dst_pf[2] = new CvPoint2D32f(200,70);
CvMat perspective_matrix = Cv.GetAffineTransform(src_pf, dst_pf);
Cv.WarpAffine(src, dst, perspective_matrix)

In Android, the code should look like this:

MatOfPoint2f src_pf = new MatOfPoint2f();
MatOfPoint2f dst_pf = new MatOfPoint2f();
//how do I set up the position numbers in MatOfPoint2f here?
Mat perspective_matrix = Imgproc.getAffineTransform(src_pf, dst_pf);
Imgproc.warpAffine(src, dst, perspective_matrix);

How do I setup the position numbers in MatOfPoint2f?