我正在使用OpenCV计算的单应性.我目前使用此单应性来使用下面的函数转换点.这个函数执行我需要的任务但是我不知道它是如何工作的.
任何人都可以一行一行地解释最后3行代码背后的逻辑/理论,我知道这会改变点x,y但是我不清楚它为什么会起作用:
为什么Z
,px
并py
以这种方式计算,元素h
对应的是什么?
非常感谢您的评论:)
double h[9];
homography = cvMat(3, 3, CV_64F, h);
CvMat ps1 = cvMat(MAX_CALIB_POINTS/2,2,CV_32FC1, points1);
CvMat ps2 = cvMat(MAX_CALIB_POINTS/2,2,CV_32FC1, points2);
cvFindHomography(&ps1, &ps2, &homography, 0);
...
// This is the part I don't fully understand
double x = 10.0;
double y = 10.0;
double Z = 1./(h[6]*x + h[7]*y + h[8]);
px = (int)((h[0]*x + h[1]*y + h[2])*Z);
py = (int)((h[3]*x + h[4]*y + h[5])*Z);
Run Code Online (Sandbox Code Playgroud)