You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include "API_VideoStitch.h"
|
|
|
|
|
#include "opencv2/opencv.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 全景图配置
|
|
|
|
|
struct PanInfo
|
|
|
|
|
{
|
|
|
|
|
int m_pan_width;
|
|
|
|
|
int m_pan_height;
|
|
|
|
|
float scale;// 比例尺
|
|
|
|
|
float map_shiftX;// 平移X
|
|
|
|
|
float map_shiftY;// 平移Y
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 像方-物方转换关系
|
|
|
|
|
struct TForm
|
|
|
|
|
{
|
|
|
|
|
cv::Mat R;
|
|
|
|
|
cv::Mat T;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 投影关系,描述反算过程
|
|
|
|
|
struct Proj
|
|
|
|
|
{
|
|
|
|
|
TForm tf_p2g;//从帧到地理坐标系的Rt矩阵
|
|
|
|
|
TForm tf_g2p;//从地理坐标系到帧的Rt矩阵
|
|
|
|
|
PanInfo panPara;//全景图配置
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class VideoStitch:public API_VideoStitch
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
VideoStitch(SINT32 nWidth, SINT32 nHeight);
|
|
|
|
|
~VideoStitch();
|
|
|
|
|
|
|
|
|
|
void Test();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
BBOOL Init(FrameInfo info);
|
|
|
|
|
|
|
|
|
|
BYTE8 Updata(cv::Mat img, FrameInfo para);
|
|
|
|
|
|
|
|
|
|
// 投影:从全景图到帧
|
|
|
|
|
cv::Point2f project(cv::Point2f pos_pan, Proj m_Proj);
|
|
|
|
|
|
|
|
|
|
// 反投影:从帧到全景图
|
|
|
|
|
cv::Point2f back_project(cv::Point2f pos_frame, Proj m_Proj);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
FrameInfo originPoint;//成图初始点,作为拼接参考
|
|
|
|
|
|
|
|
|
|
// 帧像方-地理坐标
|
|
|
|
|
cv::Point2f Trans_uv2Geo(cv::Point2f pos_frame, TForm form);
|
|
|
|
|
|
|
|
|
|
// 地理坐标-帧像方
|
|
|
|
|
cv::Point2f Trans_Geo2uv(cv::Point2f pos_geo, TForm form);
|
|
|
|
|
|
|
|
|
|
// 从全景图->地理
|
|
|
|
|
cv::Point2f Trans_pan2Geo(cv::Point2f pos_pan, PanInfo panPara);
|
|
|
|
|
|
|
|
|
|
// 地理->全景图
|
|
|
|
|
cv::Point2f Trans_Geo2pan(cv::Point2f pos_geo, PanInfo panPara);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 平移矩阵,以初始化点为基准,计算当前位置在初始点的地理坐标,那么当前帧所有点的坐标做此平移
|
|
|
|
|
cv::Mat Mat_TransENGMove(FrameInfo info);
|
|
|
|
|
|
|
|
|
|
// 机体ENG(东北地)到像方的 旋转矩阵
|
|
|
|
|
cv::Mat Mat_TransENG2uv(FrameInfo info);
|
|
|
|
|
|
|
|
|
|
// 计算当前帧像方-成图坐标系R t(反投影关系)
|
|
|
|
|
void AnlayseTform(FrameInfo info);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
Proj m_Proj;// 当前帧投影矩阵集合
|
|
|
|
|
|
|
|
|
|
cv::Mat m_pan;//全景图
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|