Ask Your Question
0

need a help on MatOfPoint2f

asked May 27 '13

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?

Preview: (hide)

1 answer

Sort by » oldest newest most voted
1

answered May 28 '13

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.

Preview: (hide)

Question Tools

Stats

Asked: May 27 '13

Seen: 581 times

Last updated: May 28 '13