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, and matrix buil like this x'i = (Ax + By + C)/(ax+ by + c)

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

CvMat* warp_matrix = cvCreateMat(3,3,CV_32FC1);
srcQuad... some code here

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

p.x=(matrix*p.x+matrix*p.y+matrix)/(matrix*p.x+matrix*p.y+matrix);
p.y=(matrix*p.x+matrix*p.y+matrix)/(matrix*p.x+matrix*p.y+matrix);

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)

edit retag close merge delete

have you compared your result with the output of cv::transform(...) ?

Sort by » oldest newest most voted Hi! You should transpose your matrix on image to get the formula below it. OpenCV uses this formula: where (Mij) - transformation matrix. About perspective transformation in OpenCV you can read here.

more