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.

166 lines
4.3 KiB

/*
* @Author: your name
* @Date: 2022-04-20 15:49:50
* @LastEditTime: 2025-09-25 17:22:34
* @LastEditors: xiewenji 527774126@qq.com
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @FilePath: /ZCXD_MonitorPlatform/src/CoreLogicModule/include/CamDeal.h
*/
#ifndef CameraCheckAnalysisy_H_
#define CameraCheckAnalysisy_H_
#include <mutex>
#include <vector>
#include <thread>
#include <string>
#include <stdio.h>
#include <condition_variable>
#include "Define_Base.h"
#include "ImgCheckBase.h"
#include "ImageDetBase.h"
#include "ImgCheckConfig.h"
#include "CheckErrorCodeDefine.hpp"
#include "ConfigBase.h"
#include "CheckConfigDefine.h"
#include "ImageDetConfig.h"
#include "Define_Product.hpp"
#include "CameraResult.h"
#include "DetLog.h"
#include "ImageResultJudge.h"
#include "CheckResultJson.h"
#include "Edge_Search.h"
#include "AI_Mark_Det.h"
#include "AI_ZF_Det.h"
#include "ImageMerge.h"
#include "QX_Merge_Analysis.h"
using namespace std;
using namespace cv;
// 相机处理类
class CameraCheckAnalysisy
{
public:
CameraCheckAnalysisy();
~CameraCheckAnalysisy();
// 相机处理类 初始化
int Init(std::string strcameraName);
int StartCheck(std::shared_ptr<CameraResult> pCamera_Check_Result);
private:
// 开启线程
int StartThread();
// 停止线程
int StopThread();
// 初始化检测分析线程类
int InitCheckAnalysisy();
// 初始化其他
int InitRun();
// 设置新的检测参数
int SetNewConfig();
// 处理每张图片
int CheckImgRun();
int Run(); // 运行;
int set_cpu_id(const std::vector<int> &cpu_set_vec);
// 等待处理图片
int WaitDetImg();
// 预处理图片
int Detect_Pre();
// 处理每张图片
int Detect_Images();
// 结果参数分析
int ResultParamJudge();
int MergeResultAnalysisy(); // 合并结果分析
int UpdateConfigStatus();
// 结果参数分析
int ResultParamJudge_New();
// 边缘处理
int ImgEdge(std::shared_ptr<ImageAllResult> L255, ChannelCheckFunction *pFuntion_L255);
// 检测MarkLine
int Det_MarkLine(const cv::Mat &L255CutImg, std::shared_ptr<ImageAllResult> L255, Base_Function_MarkLine *pFuntion);
// 预处理 字符检测
int preDet_ZF(const cv::Mat &L255CutImg, std::shared_ptr<ImageAllResult> L255);
// 预处理 标签检测
int preDet_BQ(const cv::Mat &L255CutImg, std::shared_ptr<ImageAllResult> L255);
// 边缘处理
int ImgEdge(cv::Mat img, cv::Mat &detMaskImg, cv::Rect &roi, int productIdx);
// 插入相机日志
int InsertCameraLog();
ChannelCheckFunction *GetChannelFuntion(std::string strChannelName); // 获得 通道的检测功能
// 获取 检测核心库
ImgCheckBase *GetDealResult(int idx = -1);
public:
// 运行的基本参数
RunInfoST m_RunConfig;
// 检测参数模块
std::shared_ptr<ConfigBase> m_pConfig;
int m_nConfigIdx;
// 检测分析参数
AnalysisyConfigST m_AnalysisyConfig;
CommonConfigNodeST *m_pCommonAnalysisyConfig;
ALLChannelCheckFunction *m_pChannelFuntion; // 画面检测功能
BaseCheckFunction *m_pbaseCheckFunction; // 基础检测
std::shared_ptr<DetLog> m_pdetlog;
// 结果分析类
ImageResultJudge m_imageResultJudge;
// 边缘检测模块集合
Edge_Search m_Edge_Search;
// Mark检测
AI_Mark_Det m_MarkDet;
// 字符检测
AI_ZF_Det m_ZF_Det;
ImageMerge m_ImageMerge;
private:
// 相机ID
std::string m_strcameraName;
int m_nErrorCode; // 错误代码
bool m_bInitSucc; // 初始化状态
bool m_bExit; // 是否退出检测
int nLastCheckAnalysisyThreadIdx;
// 图片处理线程
std::shared_ptr<std::thread> ptr_thread_Run;
std::shared_ptr<CameraResult> m_pCheck_Result;
bool m_bHaveImgeDet; // 是否有图片需要检查
std::mutex mtx_WaiteImg; // 等待图片的锁
std::condition_variable cond_WaiteImg; // 条件变量,是否有图片需要检查
std::string m_strRootPath_MergeImg;
private:
// 检测核心库
ImgCheckBase *m_pImgCheckAnalysisy[IMGCHECKANALYSISY_NUM];
CheckResultJson m_CheckResultJson;
std::shared_ptr<QX_Merge_Analysis> m_pQX_Merge_Analysis;
private:
private:
};
#endif