|
|
/*
|
|
|
* @Author: your name
|
|
|
* @Date: 2022-04-20 15:49:50
|
|
|
* @LastEditTime: 2025-09-17 20:05:16
|
|
|
* @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 "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 "CameraCheckAnalysisy.hpp"
|
|
|
#include "Product.h"
|
|
|
#include "ParmNameChange/ParmNameChange.h"
|
|
|
#include "QX_Merge_Analysis.h"
|
|
|
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 ReJson(std::shared_ptr<shareImage> p, 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();
|
|
|
|
|
|
// 核对参数版本号
|
|
|
int CheckConfigVersion(void *pconfig1);
|
|
|
|
|
|
private:
|
|
|
// 开启线程
|
|
|
int StartThread();
|
|
|
// 停止线程
|
|
|
int StopThread();
|
|
|
|
|
|
// 退出系统
|
|
|
int ExitSystem();
|
|
|
|
|
|
// 初始化相机检测分析类
|
|
|
int InitCameraCheckAnalysisy();
|
|
|
|
|
|
// 初始化
|
|
|
int InitData();
|
|
|
|
|
|
// 处理产品
|
|
|
int Det_Product(std::shared_ptr<Product> &product);
|
|
|
std::shared_ptr<Product> GetProduct();
|
|
|
|
|
|
// 联合分析
|
|
|
int AnalysiyAll(int productIdx);
|
|
|
|
|
|
// 设置最终结果
|
|
|
int SetProductResult(std::shared_ptr<Product> product);
|
|
|
// 设置检测完成
|
|
|
int SetSetComplet_New(std::shared_ptr<Product> product, int nerror);
|
|
|
|
|
|
// 加载图片 队列
|
|
|
int PushInImg_New(std::shared_ptr<shareImage> p);
|
|
|
|
|
|
cv::Mat hconcatWithFirstBase(const cv::Mat &img1, const cv::Mat &img2, int interpolation);
|
|
|
|
|
|
int MergeShowImg(std::shared_ptr<Product> product); // 合并图片
|
|
|
|
|
|
// 清理产品list
|
|
|
void Clear_m_ProductList();
|
|
|
|
|
|
// 异常返回
|
|
|
int ErrorReturn(std::shared_ptr<shareImage> p);
|
|
|
|
|
|
std::shared_ptr<Product> GetProduct(std::string strProduct);
|
|
|
|
|
|
int InitAIFactory();
|
|
|
|
|
|
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;
|
|
|
// 检测参数模块
|
|
|
|
|
|
ConfigManagerBase *m_pConfigManager;
|
|
|
|
|
|
// 图片处理线程
|
|
|
|
|
|
// 相机处理模块,负责完成对应相机图片的处理功能。
|
|
|
std::unordered_map<std::string, std::shared_ptr<CameraCheckAnalysisy>> m_pCameraCheckAnalysisyList;
|
|
|
|
|
|
PRINT_LOG_ m_PrintLog;
|
|
|
// 互斥锁定义
|
|
|
private:
|
|
|
// 产品队列
|
|
|
std::vector<std::shared_ptr<Product>> m_ProductList;
|
|
|
std::mutex mtx_ProductList; // 互斥量
|
|
|
std::condition_variable ProductList_cond; // 条件变量,
|
|
|
|
|
|
std::shared_ptr<DetLog> m_pdetlog;
|
|
|
|
|
|
// 当前检测产品的个数
|
|
|
int m_CurProductIdx = 0;
|
|
|
|
|
|
std::queue<std::shared_ptr<CheckResult>> m_CheckResultList; // 检测结果
|
|
|
std::mutex mtx_CheckResult; // 互斥锁,用于保护数据队列
|
|
|
std::condition_variable CheckResult_cond; // 条件变量,用于同步生产者和消费者线程
|
|
|
|
|
|
private:
|
|
|
int m_nErrorCode; // 错误代码
|
|
|
bool m_bInitSucc; // 初始化状态
|
|
|
bool m_bExit; // 是否退出检测
|
|
|
|
|
|
std::string m_strTest;
|
|
|
|
|
|
ParmNameChange *m_pParamName;
|
|
|
|
|
|
};
|
|
|
|
|
|
#endif |