|
|
#ifndef Down_Angle_Detect_H_
|
|
|
#define Down_Angle_Detect_H_
|
|
|
|
|
|
#include "BaseInclude.h"
|
|
|
#include "AI_Moudel.hpp"
|
|
|
#include "BlobBase.h"
|
|
|
|
|
|
#include <opencv2/freetype.hpp> //0928-add
|
|
|
#include <cmath> //1028-add
|
|
|
|
|
|
class Down_Angle_Detect: public ImgCheckBase
|
|
|
{
|
|
|
public:
|
|
|
Down_Angle_Detect();
|
|
|
~Down_Angle_Detect();
|
|
|
|
|
|
// 初始化参数 pconfig 参数指针 返回:0 成功 其他异常
|
|
|
int RunStart(void *pconfig1 = NULL);
|
|
|
|
|
|
// 阻塞式检测
|
|
|
int CheckImg(std::shared_ptr<shareImage> p, std::shared_ptr<CheckResult> &pResult);
|
|
|
|
|
|
int CheckRotateTemplete2Img2(std::shared_ptr<shareImage> p, std::shared_ptr<CheckResult> &pResult, std::shared_ptr<CheckResult> &pResultOut); //1107-add 添加检查模板图像和旋转之后的图像的函数
|
|
|
|
|
|
// 更新参数 pconfig 参数指针,nConfigType 需要更新的参数类型 返回:0 成功 其他异常
|
|
|
int UpdateConfig(void *pconfig, int nConfigType);
|
|
|
|
|
|
|
|
|
private:
|
|
|
// 检测
|
|
|
int CheckRun();
|
|
|
|
|
|
cv::Rect GetDetRoi(const cv::Mat &img);
|
|
|
|
|
|
// 初始化数据
|
|
|
int CheckImgInit();
|
|
|
// 初始化模型
|
|
|
int InitModel();
|
|
|
|
|
|
int AI_Run(const cv::Mat &img, cv::Point s2StartP, double LabelP1P2distance, float &outAngle, cv::Point2f &CenterP,
|
|
|
cv::Point &LeftDownP, cv::Point &RightDownP, int &minRectWidth, int &minRectHeight, cv::Mat &resultChipMaskImg); // 1107-add
|
|
|
|
|
|
// int Draw3(const cv::Mat &img, cv::Mat &resultimg, cv::Point s2StartP, cv::Point LabelCircleP, cv::Point startP, cv::Point endP, bool drawLineFlag); // 1029-add
|
|
|
int Draw3(const cv::Mat &img, cv::Mat &resultimg, cv::Point s2StartP, cv::Point s2OutCenterP, cv::Point LabelCircleP, cv::Point startS2LabelP, cv::Point endS2LabelP, cv::Point startLeftB_P, cv::Point endRightB_P,bool drawLineFlag); // 1107-add
|
|
|
|
|
|
// 原始 size 到 显示图
|
|
|
int GetShowSrcImg(const cv::Mat &img, cv::Mat &sizeimg); // 1013-add
|
|
|
int AddResultErrorImg(cv::Mat &src); // 1013-add
|
|
|
|
|
|
float calculate_angle2(cv::Point Mar1Point, cv::Point Mar2Point); // 1028-add
|
|
|
float calculate_angle2f(cv::Point2f Mar1Point, cv::Point2f Mar2Point); // 1107-add
|
|
|
// double CalculateAngle(cv::Point Mar1Point, cv::Point Mar2Point); //1029-add
|
|
|
|
|
|
double calculateSplitLineAngle(const cv::Mat& binaryImage);
|
|
|
|
|
|
private:
|
|
|
int m_nErrorCode; // 错误代码
|
|
|
std::shared_ptr<shareImage> DetImgInfo_shareP;
|
|
|
std::shared_ptr<CheckResult> m_CheckResult_shareP;
|
|
|
|
|
|
|
|
|
std::shared_ptr<AI_Model_ConfigList> m_AIModelConfigList;
|
|
|
std::shared_ptr<CheckBaseConfig> m_CheckBaseConfig;
|
|
|
RunInfoST m_pRunConfig;
|
|
|
|
|
|
ERROR_DOTS_BLOBS m_blob;
|
|
|
bool bwriteImg;
|
|
|
|
|
|
bool m_Update_config;
|
|
|
|
|
|
std::vector<BlobResult> m_resultList;
|
|
|
cv::Rect m_AlignMaxRoi;
|
|
|
cv::Mat m_resultImg;
|
|
|
cv::Mat m_reconstructImg;
|
|
|
std::string m_strCheckBaseConfigPath;
|
|
|
|
|
|
|
|
|
// 检查缺陷对应参数中的位置。
|
|
|
int m_QxInParamListIdx[CONFIG_QX_NAME_count] = {0};
|
|
|
|
|
|
cv::Point2f m_LabelCenterP;//当前模板的中心点
|
|
|
|
|
|
};
|
|
|
|
|
|
#endif
|