|
|
/*
|
|
|
* @Author: your name
|
|
|
* @Date: 2022-04-20 15:49:50
|
|
|
* @LastEditTime: 2025-07-26 11:23:45
|
|
|
* @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 ALLImgCheckAnalysisy_H_
|
|
|
#define ALLImgCheckAnalysisy_H_
|
|
|
|
|
|
#include <iostream>
|
|
|
#include <stdio.h>
|
|
|
#include <sys/time.h>
|
|
|
#include <opencv2/opencv.hpp>
|
|
|
#include <condition_variable>
|
|
|
#include <mutex>
|
|
|
#include <vector>
|
|
|
#include <thread>
|
|
|
#include <string>
|
|
|
#include <stdio.h>
|
|
|
#include <stdlib.h>
|
|
|
#include <unistd.h>
|
|
|
#include "BlobBase.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 "CameraCheckAnalysisy.hpp"
|
|
|
|
|
|
using namespace std;
|
|
|
using namespace cv;
|
|
|
|
|
|
class ALLImgCheckAnalysisy : public ALLImgCheckBase
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
ALLImgCheckAnalysisy();
|
|
|
~ALLImgCheckAnalysisy();
|
|
|
|
|
|
// 初始化参数 pconfig 参数指针 返回:0 成功 其他异常
|
|
|
int RunStart(void *pconfig1);
|
|
|
|
|
|
// 设置检测数据,并开启检测 返回:0 成AT_THRESHOLD_TYPE_READY功 其他异常
|
|
|
int SetDataRun_SharePtr(std::shared_ptr<shareImage> p);
|
|
|
|
|
|
// 获取结果信息 返回:0 成功 其他异常
|
|
|
int GetCheckReuslt(std::shared_ptr<CheckResult> &pResult);
|
|
|
|
|
|
int CheckImg(std::shared_ptr<shareImage> p, std::shared_ptr<CheckResult> &pResult);
|
|
|
|
|
|
// 获取检测库 状态信息 返回:CHECK_THREAD_RUN_STATUS
|
|
|
int GetStatus();
|
|
|
|
|
|
// 更新参数 pconfig 参数指针,nConfigType 需要更新的参数类型 返回:0 成功 其他异常
|
|
|
int UpdateConfig(void *pconfig, int nConfigType);
|
|
|
|
|
|
std::string GetVersion();
|
|
|
|
|
|
std::string GetErrorInfo();
|
|
|
|
|
|
private:
|
|
|
// 加载运行参数
|
|
|
int LoadRunConfig(void *p);
|
|
|
|
|
|
// 加载分析参数
|
|
|
int LoadCheckConfig(void *p);
|
|
|
|
|
|
/// @brief 初始化并且启动程序
|
|
|
/// @return
|
|
|
int InitRun();
|
|
|
|
|
|
/// @brief 开启检测
|
|
|
/// @return
|
|
|
int StartCheck();
|
|
|
|
|
|
/// @brief 设置空闲
|
|
|
/// @return
|
|
|
int SetIDLE();
|
|
|
|
|
|
private:
|
|
|
// 开启线程
|
|
|
int StartThread();
|
|
|
// 停止线程
|
|
|
int StopThread();
|
|
|
|
|
|
// 退出系统
|
|
|
int ExitSystem();
|
|
|
|
|
|
// 初始化相机检测分析类
|
|
|
int InitCameraCheckAnalysisy();
|
|
|
// 设置相机图片并开始检测分析
|
|
|
int SetCameraImgAndStartDet(std::string strcameraName, std::shared_ptr<Camera_Check_Result> pCamera);
|
|
|
|
|
|
// 初始化
|
|
|
int InitData();
|
|
|
|
|
|
// 处理产品
|
|
|
int Det_Product();
|
|
|
|
|
|
// 联合分析
|
|
|
int AnalysiyAll(int productIdx);
|
|
|
// 暗点联合分析
|
|
|
int AD_AllChannelAnalysisy(int productIdx, std::shared_ptr<PRODUCT_DET_RESULT_> &pProduct);
|
|
|
int AD_AllChannelAnalysisy_New();
|
|
|
int POL_AllChannelAnalysisy_New();
|
|
|
// 设置最终结果
|
|
|
int SetProductResult();
|
|
|
// 设置检测完成
|
|
|
int SetSetComplet(int productIdx, int result, int nerror);
|
|
|
int SetSetComplet_New(int result, int nerror);
|
|
|
|
|
|
// 处理数量
|
|
|
int DetListNum();
|
|
|
|
|
|
// 加载图片 队列
|
|
|
int PushInImg_New(std::shared_ptr<shareImage> p);
|
|
|
|
|
|
// 当前检查环境判断
|
|
|
int CurCheckListStatus();
|
|
|
|
|
|
// 异常返回
|
|
|
int ErrorReturn(std::shared_ptr<shareImage> p);
|
|
|
|
|
|
float CalImgScorl(cv::Mat det_img, cv::Mat up_img);
|
|
|
|
|
|
int AddStrToLog(int productIdx, std::string str);
|
|
|
int AddStrToLog_New(std::string str);
|
|
|
// 设置新的检测参数
|
|
|
int SetNewConfig();
|
|
|
ChannelCheckFunction *GetChannelFuntion(std::string strChannelName); // 获得 通道的检测功能
|
|
|
|
|
|
private:
|
|
|
// 图片处理线程
|
|
|
std::shared_ptr<std::thread> ptr_thread_Run;
|
|
|
int Run(); // 运行;
|
|
|
int set_cpu_id(const std::vector<int> &cpu_set_vec);
|
|
|
|
|
|
private:
|
|
|
RunInfoST m_RunConfig;
|
|
|
// 检测参数模块
|
|
|
ConfigBase *m_pConfig;
|
|
|
ConfigBase *m_pConfig_Cam2;
|
|
|
// 图片处理线程
|
|
|
|
|
|
// 相机处理模块,负责完成对应相机图片的处理功能。
|
|
|
CameraCheckAnalysisy *m_pCameraCheckAnalysisy[MAX_Camera_NUM];
|
|
|
|
|
|
PRINT_LOG_ m_PrintLog;
|
|
|
// 互斥锁定义
|
|
|
private:
|
|
|
// 产品的所有信息
|
|
|
std::shared_ptr<Product_Check_Result> m_ProductImgDetResult_New;
|
|
|
|
|
|
std::vector<std::shared_ptr<PRODUCT_DET_RESULT_>> m_ProductImgDetResultList;
|
|
|
|
|
|
std::mutex mtx_ProductImgDetResultList; // 互斥锁,用于保护数据队列
|
|
|
|
|
|
std::mutex mtx_DetSingle; // 互斥量
|
|
|
|
|
|
std::queue<std::shared_ptr<CheckResult>> m_CheckResultList; // 检测结果
|
|
|
std::mutex mtx_CheckResult; // 互斥锁,用于保护数据队列
|
|
|
std::condition_variable CheckResult_cond; // 条件变量,用于同步生产者和消费者线程
|
|
|
|
|
|
std::vector<std::string> Last_det_LogList; // 上一个产品的检测日志
|
|
|
|
|
|
std::mutex mtx_Last_det_LogList; // 互斥量
|
|
|
|
|
|
private:
|
|
|
int m_nErrorCode; // 错误代码
|
|
|
bool m_bInitSucc; // 初始化状态
|
|
|
bool m_bExit; // 是否退出检测
|
|
|
|
|
|
std::shared_ptr<ImageDetResult> m_OneImg_Result_shareP;
|
|
|
std::shared_ptr<ImageDetconfig> DetImgInfo_shareP;
|
|
|
|
|
|
std::string m_strTest;
|
|
|
|
|
|
// 检测分析参数
|
|
|
AnalysisyConfigST m_AnalysisyConfig;
|
|
|
ALLChannelCheckFunction *m_pChannelFuntion; // 画面检测功能
|
|
|
// 当前检测产品的个数
|
|
|
int m_CurProductIdx;
|
|
|
|
|
|
ReJson_Status m_reJsonStatus_push; // 复测状态;送图
|
|
|
ReJson_Status m_reJsonStatus_Det; // 复测状态;复测
|
|
|
};
|
|
|
|
|
|
#endif |