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.
154 lines
4.5 KiB
154 lines
4.5 KiB
/*
|
|
* @Author: your name
|
|
* @Date: 2022-04-20 15:49:50
|
|
* @LastEditTime: 2022-09-23 21:51:58
|
|
* @LastEditors: sueRimn
|
|
* @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 "AICheck.h"
|
|
#include "ImgCheckBase.h"
|
|
#include "ImageDetBase.h"
|
|
#include "ImgCheckConfig.h"
|
|
#include "CheckErrorCodeDefine.hpp"
|
|
#include "ConfigBase.h"
|
|
#include "CheckSODefine.hpp"
|
|
#include "CheckConfigDefine.h"
|
|
#include "EdgeDet.h"
|
|
#include "ImageDetConfig.h"
|
|
#include "Define_Product.hpp"
|
|
#include "AI_Mark_Det.h"
|
|
|
|
using namespace std;
|
|
using namespace cv;
|
|
// 相机处理类
|
|
class CameraCheckAnalysisy
|
|
{
|
|
|
|
public:
|
|
CameraCheckAnalysisy();
|
|
~CameraCheckAnalysisy();
|
|
|
|
// 相机处理类 初始化
|
|
int Init(Camera_IDX camera_ID);
|
|
int StartCheck(std::shared_ptr<Camera_Check_Result> pCamera_Check_Result);
|
|
|
|
private:
|
|
// 开启线程
|
|
int StartThread();
|
|
// 停止线程
|
|
int StopThread();
|
|
|
|
// 初始化检测分析线程类
|
|
int InitCheckAnalysisy();
|
|
// 初始化其他
|
|
int InitRun();
|
|
// 设置新的检测参数
|
|
int SetNewConfig();
|
|
|
|
int InitMarkLine();
|
|
|
|
// 处理每张图片
|
|
int CheckImgRun();
|
|
|
|
int Run(); // 运行;
|
|
int set_cpu_id(const std::vector<int> &cpu_set_vec);
|
|
// 等待处理图片
|
|
int WaitDetImg();
|
|
// 增加日志
|
|
int AddStrToLog_New(std::string str);
|
|
|
|
// 预处理图片
|
|
int Detect_Pre();
|
|
|
|
// 处理每张图片
|
|
int Detect_Images();
|
|
|
|
// 边缘处理
|
|
int ImgEdge(cv::Mat img, bool bUseDraw, const cv::Mat ¶MaskImg, int thresholdvalue, int AIErodesize, bool bUseAIDet, cv::Mat &detMaskImg, cv::Rect &roi, int productIdx);
|
|
|
|
// 插入相机日志
|
|
int InsertCameraLog();
|
|
|
|
ChannelCheckFunction *GetChannelFuntion(std::string strChannelName); // 获得 通道的检测功能
|
|
|
|
// 特征主定位
|
|
int Feature_Align(const cv::Mat &detSrcImg, int nproductIdx, cv::Rect Det_CropRoi, ChannelCheckFunction *pFuntion_L255, const cv::Mat &detImg_mask, bool bsave = false, bool bsaveprocessimg = false);
|
|
// 预处理 字符检测
|
|
int preDet_ZF(std::shared_ptr<ImageDetconfig> p, std::shared_ptr<ImageDetResult> &pResult);
|
|
|
|
// 检测MarkLine
|
|
int Det_MarkLine(const cv::Mat &detSrcImg, cv::Rect Det_CropRoi, Base_Function_MarkLine *pFuntion, cv::Mat &detImg_mask, cv::Rect &markRoi_x, cv::Rect &markRoi_y, bool bsaveprocessimg = false);
|
|
|
|
// 获取 检测核心库
|
|
ImgCheckBase *GetDealResult(int idx = -1);
|
|
|
|
int GetAndAnalysisyCheckResult(std::shared_ptr<ImageDetResult> &pResult);
|
|
|
|
public:
|
|
// 运行的基本参数
|
|
RunInfoST m_RunConfig;
|
|
// 检测参数模块
|
|
ConfigBase *m_pConfig;
|
|
PRINT_LOG_ m_PrintLog;
|
|
|
|
AI_Edge_Algin::DetConfig AI_detConfig;
|
|
Align_Result m_align_Result;
|
|
// 图片特征定位
|
|
Image_Feature_Algin m_Image_Feature_Algin;
|
|
// 检测分析参数
|
|
AnalysisyConfigST m_AnalysisyConfig;
|
|
ALLChannelCheckFunction *m_pChannelFuntion; // 画面检测功能
|
|
BaseCheckFunction *m_pbaseCheckFunction; // 基础检测
|
|
|
|
std::shared_ptr<ImageDetResult> m_OneImg_Result_shareP;
|
|
std::shared_ptr<ImageDetconfig> DetImgInfo_shareP;
|
|
std::string m_strCameraName;
|
|
|
|
private:
|
|
// 相机ID
|
|
Camera_IDX m_camera_ID;
|
|
int m_ncamera_idx;
|
|
|
|
int m_nErrorCode; // 错误代码
|
|
bool m_bInitSucc; // 初始化状态
|
|
bool m_bExit; // 是否退出检测
|
|
int nLastCheckAnalysisyThreadIdx;
|
|
// 图片处理线程
|
|
std::shared_ptr<std::thread> ptr_thread_Run;
|
|
|
|
// 单相机的相关结果信息
|
|
std::shared_ptr<Camera_Check_Result> m_pCamera_Check_Result;
|
|
|
|
bool m_bHaveImgeDet; // 是否有图片需要检查
|
|
std::mutex mtx_WaiteImg; // 等待图片的锁
|
|
std::condition_variable cond_WaiteImg; // 条件变量,是否有图片需要检查
|
|
|
|
private:
|
|
// 检测核心库
|
|
ImgCheckBase *m_pImgCheckAnalysisy[IMGCHECKANALYSISY_NUM];
|
|
|
|
AI_IMG_deal m_AIDeal;
|
|
OtherDet_Config m_OtherDet_Config;
|
|
// 边缘检测
|
|
EdgeDet_New m_DetEdge;
|
|
|
|
AI_Mark_Det m_MarkDet; // Mark检测
|
|
|
|
CHECK_TEM_RESULT m_TemCheck;
|
|
|
|
private:
|
|
private:
|
|
};
|
|
|
|
#endif |