Ask Your Question
0

need a help on MatOfPoint2f

asked 2013-05-27 17:10:19 -0500

Papercut gravatar image

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?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-05-28 02:14:22 -0500

Daniil Osokin gravatar image

Hi! To modify separate element use put and get methods, please check this answer: How to get and modify the pixel of Mat in Java?, also can be useful MatOfPoint2f docs.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-05-27 17:10:19 -0500

Seen: 398 times

Last updated: May 28 '13