Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Perspective Transform of one point

Hello, i use PerspectiveTransform and as a result have matrix of transformation. I need transform coordinates of ONE point using this matrix, i read that i can use coficient of matrix for calculate it, an matrix buil like this image description

x'i = (Ax + By + C)/(ax+ by + c)

y'i = (Dx + Ey + F)/(ax+ by + c)

CvPoint2D32f srcQuad[4], dstQuad[4];
CvMat* warp_matrix = cvCreateMat(3,3,CV_32FC1);
srcQuad... some code here
dstQuad... and here
cvGetPerspectiveTransform(srcQuad,dstQuad,matrix);

But when i use this formula it don`t work corectly every time

p.x=(matrix[0][0]*p.x+matrix[0][1]*p.y+matrix[0][2])/(matrix[2][0]*p.x+matrix[2][1]*p.y+matrix[2][2]);
p.y=(matrix[1][0]*p.x+matrix[1][1]*p.y+matrix[1][2])/(matrix[2][0]*p.x+matrix[2][1]*p.y+matrix[2][2]);

I think that the transformation matrix in OpenCV has a different structure, or I made ​​a mistake somewhere. Perhaps there is other variant coordinate transformation one point? And Sorry for my english)

Perspective Transform of one pointTransform

Hello, i use PerspectiveTransform and as a result have matrix of transformation. I need transform coordinates of ONE point using this matrix, i read that i can use coficient of matrix for calculate it, an matrix buil like this image description

x'i = (Ax + By + C)/(ax+ by + c)

y'i = (Dx + Ey + F)/(ax+ by + c)

CvPoint2D32f srcQuad[4], dstQuad[4];
CvMat* warp_matrix = cvCreateMat(3,3,CV_32FC1);
srcQuad... some code here
dstQuad... and here
cvGetPerspectiveTransform(srcQuad,dstQuad,matrix);

But when i use this formula it don`t work corectly every time

p.x=(matrix[0][0]*p.x+matrix[0][1]*p.y+matrix[0][2])/(matrix[2][0]*p.x+matrix[2][1]*p.y+matrix[2][2]);
p.y=(matrix[1][0]*p.x+matrix[1][1]*p.y+matrix[1][2])/(matrix[2][0]*p.x+matrix[2][1]*p.y+matrix[2][2]);

I think that the transformation matrix in OpenCV has a different structure, or I made ​​a mistake somewhere. Perhaps there is other variant coordinate transformation one point? And Sorry for my english)

Some trouble with Perspective Transform

Hello, i use PerspectiveTransform and as a result have matrix of transformation. I need transform coordinates of ONE point using this matrix, i read that i can use coficient of matrix for calculate it, an and matrix buil like this image description

x'i = (Ax + By + C)/(ax+ by + c)

y'i = (Dx + Ey + F)/(ax+ by + c)

CvPoint2D32f srcQuad[4], dstQuad[4];
CvMat* warp_matrix = cvCreateMat(3,3,CV_32FC1);
srcQuad... some code here
dstQuad... and here
cvGetPerspectiveTransform(srcQuad,dstQuad,matrix);

But when i use this formula it don`t work corectly every time

p.x=(matrix[0][0]*p.x+matrix[0][1]*p.y+matrix[0][2])/(matrix[2][0]*p.x+matrix[2][1]*p.y+matrix[2][2]);
p.y=(matrix[1][0]*p.x+matrix[1][1]*p.y+matrix[1][2])/(matrix[2][0]*p.x+matrix[2][1]*p.y+matrix[2][2]);

I think that the transformation matrix in OpenCV has a different structure, or I made ​​a mistake somewhere. Perhaps there is other variant coordinate transformation one point? And Sorry for my english)