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.
73 lines
1.9 KiB
73 lines
1.9 KiB
|
7 months ago
|
#ifndef _FEASTITCH_H
|
||
|
|
#define _FEASTITCH_H
|
||
|
|
#include "API_FeaStitch.h"
|
||
|
|
#include "opencv2/opencv.hpp"
|
||
|
|
#include "Arith_BATask.h"
|
||
|
|
#include <map>
|
||
|
|
|
||
|
|
// 定义出界方向枚举
|
||
|
|
enum class EdgeDirection
|
||
|
|
{
|
||
|
|
NONE, // 未出界
|
||
|
|
LEFT, // 左边界
|
||
|
|
RIGHT, // 右边界
|
||
|
|
TOP, // 上边界
|
||
|
|
BOTTOM, // 下边界
|
||
|
|
TOP_LEFT, // 左上角
|
||
|
|
TOP_RIGHT, // 右上角
|
||
|
|
BOTTOM_LEFT,// 左下角
|
||
|
|
BOTTOM_RIGHT// 右下角
|
||
|
|
};
|
||
|
|
|
||
|
|
class FeaStitch :public API_FeaStitch
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
FeaStitch();
|
||
|
|
~FeaStitch();
|
||
|
|
|
||
|
|
GenPanInfo Init(GD_VIDEO_FRAME_S img,FrameInfo info);
|
||
|
|
|
||
|
|
// 当前帧设为拼接基准
|
||
|
|
void SetBase(cv::Mat& img, FrameInfo& info, EdgeDirection edgeDirection = EdgeDirection::NONE);
|
||
|
|
|
||
|
|
SINT32 Run(GD_VIDEO_FRAME_S img, FrameInfo para);
|
||
|
|
|
||
|
|
public:
|
||
|
|
|
||
|
|
GD_VIDEO_FRAME_S ExportPanAddr();
|
||
|
|
|
||
|
|
cv::Mat ExportPanMat();
|
||
|
|
|
||
|
|
FeatureMatcher* _FeaMatcher;//特征匹配
|
||
|
|
|
||
|
|
private:
|
||
|
|
std::vector<FrameInfo> _paraVec; // 帧参数
|
||
|
6 months ago
|
//std::vector<cv::Mat> _imgVec; //图像缓存
|
||
|
7 months ago
|
std::vector<std::vector<cv::KeyPoint>> _keypointsVec; // 特征点
|
||
|
|
std::vector<cv::Mat> _descriptorsVec; // 描述子
|
||
|
|
std::vector<cv::Mat_<double>> _currMatrix;//当前H矩阵
|
||
|
|
int _totalFrameCnt;//处理帧计数
|
||
|
|
int _failedFrameCnt;//匹配失败计数
|
||
|
|
|
||
|
|
private:
|
||
|
|
GenPanInfo _panPara;//全景图配置
|
||
|
|
cv::Mat _panImage; //全景图
|
||
|
|
|
||
|
|
// 检测图像是否接近边缘,返回出界方向
|
||
|
6 months ago
|
EdgeDirection isNearEdge(cv::Mat& H,cv::Size size);
|
||
|
7 months ago
|
|
||
|
|
// 根据出界方向计算初始偏移量
|
||
|
|
void calculateInitialOffset(EdgeDirection direction, int& offsetX, int& offsetY);
|
||
|
|
|
||
|
|
float calculateIOU(const cv::Mat& H1, const cv::Mat& H2, const cv::Size& imgSize);
|
||
|
|
|
||
|
6 months ago
|
// 检查H矩阵连续性
|
||
|
|
bool checkHContinuity(const cv::Mat& H, const cv::Size& imgSize);
|
||
|
|
|
||
|
|
// 检查最终H矩阵有效性
|
||
|
|
bool checkFinalHValidity(const cv::Mat& H, const cv::Size& imgSize);
|
||
|
7 months ago
|
};
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
#endif
|