1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//
// Created by Scheaven on 2020/5/22.
//
 
#include "homography_util.h"
 
cv::Point2f getTransPoint(const cv::Point2f rightPoint, cv::Mat homography)
{
    float rightP[3][1], leftP[3][1];
    rightP[0][0] = rightPoint.x;
    rightP[1][0] = rightPoint.y;
    rightP[2][0] = 1.0;
    for(int i=0;i<3;++i){//矩阵c=a*b
        for(int j=0;j<1;++j)
        {
            leftP[i][j]=0;
            for(int k=0;k<3;++k)
            {
                leftP[i][j] += homography.at<double>(i,k)*rightP[k][j];
            }
        }
    }
 
    float x = leftP[0][0] / leftP[2][0];
    float y = leftP[1][0] / leftP[2][0];
    return cv::Point2f(x, y);
}