image_framework_ymj/image_framework/algorithm/Libapi2d.h

56 lines
1.8 KiB
C
Raw Permalink Normal View History

2024-12-06 16:25:16 +08:00
#ifndef LIBAPI_2D_H
#define LIBAPI_2D_H
#include "Libapi2D3D.h"
#include <iostream>
#include <vector>
#include <opencv2/opencv.hpp>
class Cal2D
{
public:
//广角摄像机和高清相机图像映射
static int LibapiGet2D2DMapRect(cv::Mat& dst_im, bool fake = true, std::string fakeFilePath = "");
//读取广角相机图像
static int LibapiCapLQImage(cv::Mat& dst_im);
//读取高清图像
static int LibapiCapHQImage(CMeasureInfo* measureInfoPtr, std::shared_ptr<cv::Mat>& dst_im);
//从文件读取高清图像
static int LibapiReadHQImage(const std::string plyPath, cv::Mat& dst_im);
//保存高清图像
static int LibapiCopyHQImage(cv::Mat& src_im, cv::Mat& dst_im);
//图像去畸变
static int LibapiUndistort(cv::Mat& src_im, cv::Mat& dst_im);
//持续采集广角图像(PYTHON)
//AI识别广角图像中的预埋件返回其ROI坐标
static int LibapiDetectObj(CMeasureInfo* CMeasureInfo);
//通过一组ROI坐标获取ROI图像
static int LibapiGetSubImFromRois(cv::Mat& im, const int& id, const std::string& info,
std::vector<cv::Rect2f> rois, std::vector<CSubRoi>&subMat, bool fake);
//在单个预埋件图像中计算区域内预埋件边缘和角点
static int LibapiGetEdegsAndConners(cv::Mat& src,
std::vector<std::vector<float>>& sort_lines4,
std::vector<std::vector<float>>& sort_conners4);
// 挑选出的内在区域
static int LibapiSelectInnerRegion(CSubRoi& subMat);
// 挑选出2D-3D点对用于计算单应矩阵H
static int LibapiSelect2DTo3DPoints(CMeasureInfo& CMeasureInfo, CSubRoi& im,
std::vector<cv::Point2f>& vec2D, std::vector<cv::Point3f>& vec3D);
// 计算单应矩阵
static int LibapiCalH(const std::vector<cv::Point2f>& vec2D, const std::vector<cv::Point3f>& vec3D, cv::Mat& H);
// 计算预埋件角点和中心位置
static int LibapiCalScale(const CSubRoi& subConner, int H);
};
#endif