|
|
|
@ -238,6 +238,34 @@ cv::Mat GeoSolver::findHomography(Proj proj)
|
|
|
|
|
return H;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cv::Mat GeoSolver::findHomography(FrameInfo info)
|
|
|
|
|
{
|
|
|
|
|
Proj _proj = AnlayseTform(info);
|
|
|
|
|
|
|
|
|
|
std::vector<cv::Point2f> srcPoints;
|
|
|
|
|
srcPoints.push_back(cv::Point2f(0, 0));
|
|
|
|
|
srcPoints.push_back(cv::Point2f(1000, 0));
|
|
|
|
|
srcPoints.push_back(cv::Point2f(1000, 1000));
|
|
|
|
|
srcPoints.push_back(cv::Point2f(0, 1000));
|
|
|
|
|
|
|
|
|
|
// 同名点计算,从像方到全景
|
|
|
|
|
cv::Point2f leftTop_map = Trans_uv2Geo(srcPoints[0], _proj.tf_p2g);
|
|
|
|
|
cv::Point2f rightTop_map = Trans_uv2Geo(srcPoints[1], _proj.tf_p2g);
|
|
|
|
|
cv::Point2f rightBottom_map = Trans_uv2Geo(srcPoints[2], _proj.tf_p2g);
|
|
|
|
|
cv::Point2f leftBottom_map = Trans_uv2Geo(srcPoints[3], _proj.tf_p2g);
|
|
|
|
|
|
|
|
|
|
// 目标图像(全景图)的四个顶点坐标
|
|
|
|
|
std::vector<cv::Point2f> dstPoints;
|
|
|
|
|
dstPoints.push_back(leftTop_map); // 左
|
|
|
|
|
dstPoints.push_back(rightTop_map); // 右上
|
|
|
|
|
dstPoints.push_back(rightBottom_map); // 右下
|
|
|
|
|
dstPoints.push_back(leftBottom_map); // 左下
|
|
|
|
|
|
|
|
|
|
// 计算单应性矩阵 H
|
|
|
|
|
cv::Mat H = cv::findHomography(srcPoints, dstPoints);
|
|
|
|
|
return H;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 计算多边形的面积
|
|
|
|
|
double polygonArea(const vector<cv::Point2f>& points)
|
|
|
|
|