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.
102 lines
3.3 KiB
102 lines
3.3 KiB
/*
|
|
* @Author: xiewenji 527774126@qq.com
|
|
* @Date: 2025-09-23 18:06:58
|
|
* @LastEditors: xiewenji 527774126@qq.com
|
|
* @LastEditTime: 2025-09-25 10:19:29
|
|
* @FilePath: /BOE_POL_ET_Detect/AlgorithmModule/include/Edge_Search.h
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
*/
|
|
|
|
#ifndef Edge_Search_H_
|
|
#define Edge_Search_H_
|
|
#include <opencv2/opencv.hpp>
|
|
|
|
#include "CheckErrorCodeDefine.hpp"
|
|
#include "ImageDetConfig.h"
|
|
#include "CheckConfigDefine.h"
|
|
#include "AI_Edge_Algin.h"
|
|
using namespace std;
|
|
using namespace cv;
|
|
|
|
// 边缘缺陷检测
|
|
class Edge_Search
|
|
{
|
|
public:
|
|
// 检测参数和结果
|
|
struct DetConfigResult
|
|
{
|
|
Function_EdgeROI *pEdgeROI;
|
|
Function_Image_Align *pAlign;
|
|
std::shared_ptr<DetLog> pdetlog;
|
|
std::string strCamName;
|
|
|
|
bool bMode_Edge_test; // 是否是边缘测试模式
|
|
bool bDebugsaveImg; // 保存处理图片
|
|
DetConfigResult()
|
|
{
|
|
Init();
|
|
}
|
|
void Init()
|
|
{
|
|
bMode_Edge_test = false;
|
|
pEdgeROI = NULL;
|
|
pAlign = NULL;
|
|
pdetlog = NULL;
|
|
strCamName = "";
|
|
bDebugsaveImg = false;
|
|
}
|
|
};
|
|
|
|
public:
|
|
Edge_Search(/* args */);
|
|
~Edge_Search();
|
|
|
|
int Detect(const cv::Mat &detimg, DetConfigResult *pDetConfig, std::shared_ptr<EdgeDetResult> &pEdgeDetResult);
|
|
|
|
private:
|
|
int Detect_AI(const cv::Mat &detimg, DetConfigResult *pDetConfig, std::shared_ptr<EdgeDetResult> &pEdgeDetResult);
|
|
int Detect_Draw(const cv::Mat &detimg, DetConfigResult *pDetConfig, std::shared_ptr<EdgeDetResult> &pEdgeDetResult);
|
|
int Detect_Search(const cv::Mat &detimg, DetConfigResult *pDetConfig, std::shared_ptr<EdgeDetResult> &pEdgeDetResult);
|
|
int SearchEdge(const cv::Mat &detimg, cv::Rect &roi, bool bsave);
|
|
|
|
// 特征定位
|
|
int Feature_Align(const cv::Mat &detimg, DetConfigResult *pDetConfig, std::shared_ptr<EdgeDetResult> &pEdgeDetResult);
|
|
|
|
private:
|
|
std::shared_ptr<DetLog> m_pdetlog;
|
|
AI_Edge_Algin m_pAI_Edge_Algin;
|
|
// 图片特征定位
|
|
Image_Feature_Algin m_Image_Feature_Algin;
|
|
|
|
private:
|
|
cv::Mat showimg;
|
|
bool bshowimg;
|
|
|
|
double computeAverage(const std::vector<double> &data);
|
|
|
|
std::vector<double> removeOutliers(const std::vector<double> &data);
|
|
|
|
/// @brief
|
|
/// @param img 搜到图片 单通道
|
|
/// @param DirectSign 搜索方向 >0 正向,< 0 反向
|
|
/// @param Gate 阈值
|
|
/// @param BorW 搜索黑点 = 0还是白点 = 1
|
|
/// @param roi 搜索范围
|
|
/// @param StepCount 搜索点数
|
|
/// @param Limit 最小满是阈值点个数算上搜索成功
|
|
/// @return <0 搜索错误, >=0表示 搜索位置
|
|
int UDNoiseEdgeDetect(cv::Mat img, int DirectSign, int Gate, int BorW, cv::Rect roi, int StepCount, int Limit);
|
|
/// @brief
|
|
/// @param img 搜到图片 单通道
|
|
/// @param DirectSign 搜索方向 >0 正向,< 0 反向
|
|
/// @param Gate 阈值
|
|
/// @param BorW 搜索黑点 = 0还是白点 = 1
|
|
/// @param roi 搜索范围
|
|
/// @param StepCount 搜索点数
|
|
/// @param Limit 最小满是阈值点个数算上搜索成功
|
|
/// @return <0 搜索错误, >=0表示 搜索位置
|
|
int LRNoiseEdgeDetect(cv::Mat img, int DirectSign, int Gate, int BorW, cv::Rect roi, int StepCount, int Limit);
|
|
// int LRNoiseEdgeDetect(cv::Mat img,int DirectSign, int Gate,int BorW, int StartSearchSite, int Step, int StepCount, int top, int bottom, int Limit, int Depth, int MaxLimit);
|
|
};
|
|
|
|
#endif |