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.
146 lines
4.1 KiB
146 lines
4.1 KiB
/*
|
|
//实现对部分缺陷 需要进行 数量 和距离上分析的
|
|
*/
|
|
#ifndef QX_Merge_Analysis_H_
|
|
#define QX_Merge_Analysis_H_
|
|
#include <opencv2/opencv.hpp>
|
|
#include "CheckUtil.hpp"
|
|
#include <mutex>
|
|
#include <thread>
|
|
#include <condition_variable>
|
|
#include "CheckErrorCodeDefine.hpp"
|
|
#include "CheckConfigDefine.h"
|
|
#include "QX_Analysis.h"
|
|
|
|
using namespace std;
|
|
#define QX_MEREGE_CONFIG_CAMERA_NAME "left"
|
|
|
|
class QX_Merge_Analysis
|
|
{
|
|
public:
|
|
enum RUN_STATUS_
|
|
{
|
|
RUN_STATUS_NULL,
|
|
RUN_STATUS_IDLE,
|
|
RUN_STATUS_READY,
|
|
RUN_STATUS_BUSY,
|
|
RUN_STATUS_COMPLETE,
|
|
};
|
|
struct tem_AD_QX_Info
|
|
{
|
|
int qxidx = 0;
|
|
int channelidx = 0;
|
|
};
|
|
struct AD_Channel_Info_
|
|
{
|
|
cv::Rect roi;
|
|
cv::Point2f location_product_mm;
|
|
int num;
|
|
float fdis;
|
|
int dist_idx;
|
|
int num_2s;
|
|
int num_3s;
|
|
int num_1s;
|
|
vector<tem_AD_QX_Info> numIdxList;
|
|
vector<tem_AD_QX_Info> num_2sIdxList;
|
|
vector<tem_AD_QX_Info> num_3sIdxList;
|
|
AD_Channel_Info_()
|
|
{
|
|
roi = cv::Rect(0, 0, 0, 0);
|
|
location_product_mm = cv::Point2f(0, 0);
|
|
num = 0;
|
|
fdis = 999999999999;
|
|
dist_idx = 0;
|
|
num_1s = 0;
|
|
num_2s = 0;
|
|
num_3s = 0;
|
|
numIdxList.clear();
|
|
num_2sIdxList.clear();
|
|
num_3sIdxList.clear();
|
|
}
|
|
std::string GetInfo()
|
|
{
|
|
char buffer[256];
|
|
sprintf(buffer, "roi:[%d,%d,%d,%d] location [%f %f]num:%d fdis:%.2f dist_idx:%d num_1s:%d num_2s:%d num_3s:%d",
|
|
roi.x, roi.y, roi.width, roi.height, location_product_mm.x, location_product_mm.y,
|
|
num, fdis, dist_idx, num_1s, num_2s, num_3s);
|
|
return std::string(buffer);
|
|
}
|
|
};
|
|
|
|
public:
|
|
QX_Merge_Analysis();
|
|
~QX_Merge_Analysis();
|
|
static std::shared_ptr<QX_Merge_Analysis> GetInstance();
|
|
|
|
int Clear();
|
|
int AddCamer(std::string cameraName);
|
|
|
|
int InitData();
|
|
|
|
int GetReusult(QX_Analysis_Result_List *&presult);
|
|
|
|
void SetConfig(std::string cameraName, int qxidx, QXAnalysis_Config config);
|
|
void InitConfig(std::string cameraName);
|
|
void SetbaseCheckFunction(std::string cameraName, ALLChannelCheckFunction *pChannelFuntion, BaseCheckFunction *pbaseCheckFunction);
|
|
|
|
int ConfigTypeToQXAnalysis(int nconfigType);
|
|
bool Idx(int qxidx);
|
|
bool AddQxInfo(int qxidx, QX_Info qxinfo, std::shared_ptr<DetLog> plog, std::shared_ptr<DetLog> pchannelLog);
|
|
|
|
bool setSendStatus(std::string cameraName, RUN_STATUS_ status);
|
|
|
|
bool waitComplete(int timeoutMs = 15000);
|
|
std::shared_ptr<DetLog> m_pMergedetlog;
|
|
|
|
ALLChannelCheckFunction *m_pChannelFuntion;
|
|
BaseCheckFunction *m_pbaseCheckFunction;
|
|
|
|
private:
|
|
std::shared_ptr<std::thread>
|
|
ptr_thread_Run;
|
|
int Run(int nId); // 运行;
|
|
|
|
// 开启线程
|
|
int StartThread(int nId);
|
|
// 停止线程
|
|
int StopThread();
|
|
|
|
int StartAnalysis();
|
|
|
|
int Analysis_single_Config(QXAnalysis_Config *pconfig, QX_channel_List *pqxList, int qx_type, std::shared_ptr<DetLog> pchannelLog);
|
|
|
|
int Analysis_QXtype(ALL_Qx_DataList *pALLTypeqxList, int qx_idx);
|
|
int Analysis_Channel(QX_channel_List *pChannelqxList, int qx_idx);
|
|
int Judge_OK_Config();
|
|
int Judge_NG_Config();
|
|
|
|
int Analysis_AD(ALL_Qx_DataList *pALLTypeqxList, int qx_idx);
|
|
|
|
ChannelCheckFunction *GetChannelFuntion(std::string strChannelName);
|
|
|
|
double DistanceBetweenRectCenters(const cv::Rect &rect1, const cv::Rect &rect2, float fx, float fy);
|
|
|
|
private:
|
|
ALL_Qx_DataList m_QXList[QX_ANALYSIS_COUNT];
|
|
ALL_QX_ParamList m_ConfigList[QX_ANALYSIS_COUNT];
|
|
|
|
std::mutex mtx_QXList;
|
|
std::mutex mtx_ConfigList;
|
|
|
|
std::mutex mtx_status;
|
|
std::condition_variable cv_status;
|
|
RUN_STATUS_ m_status;
|
|
std::unordered_map<std::string, RUN_STATUS_> m_statusList;
|
|
std::unordered_map<std::string, std::shared_ptr<DetLog>> m_pdetlogList;
|
|
|
|
QX_Analysis_Result_List m_reultList;
|
|
|
|
bool m_bExit; // 是否退出检测
|
|
|
|
std::vector<AD_Channel_Info_> AD_list;
|
|
|
|
private:
|
|
};
|
|
|
|
#endif |