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.

117 lines
4.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#ifndef ImgCheckBase_H_
#define ImgCheckBase_H_
#include <string>
#include <memory>
#define ALL_INTERFACE_VERSION 6
#define MAX_GPU_NUM 4
enum CHECK_THREAD_RUN_STATUS
{
CHECK_THREAD_STATUS_IDLE, // 空闲 0
CHECK_THREAD_STATUS_READY, // 准备好了 1
CHECK_THREAD_STATUS_BUSY, // 运行中 2
CHECK_THREAD_STATUS_COMPLETE, // 检测完成 3
CHECK_THREAD_STATUS_ERROR, // 运行错误 4
};
// 检测工位序号
enum DETECT_WROK_IDX
{
DETECT_WROK_0, // 0工位
DETECT_WROK_1, // 1工位
DETECT_WROK_2, // 2工位
DETECT_WROK_COUNT,
};
struct RunInfoST
{
int nThreadIdx; // 线程号id
int nWorkIdx; // 工位号
int nDeviceId; // GPU 设备 号 0 或 1
int UseGPUList[MAX_GPU_NUM]; // 使用的GPU设备号
int nCpu_start_Idx; // 绑定cpu 核号,
int nCpu_num; // 8 至少需要 8个
bool bSaveCheckImg; // 是否存储
bool bRetest; // 是否是复测标志,复测不需要加载模型
int flag1;
int flag2;
std::string str1;
std::string str2;
RunInfoST()
{
nThreadIdx = 0;
nDeviceId = 0;
nWorkIdx = DETECT_WROK_0;
nCpu_start_Idx = 0;
nCpu_num = 8;
flag1 = 0;
flag2 = 0;
bRetest = false;
str1 = "";
str2 = "";
bSaveCheckImg = false;
for (int i = 0; i < MAX_GPU_NUM; i++)
{
UseGPUList[i] = -1;
}
UseGPUList[0] = 0;
UseGPUList[1] = 1;
}
void copy(RunInfoST tem)
{
for (int i = 0; i < MAX_GPU_NUM; i++)
{
this->UseGPUList[i] = tem.UseGPUList[i];
}
this->nDeviceId = tem.nDeviceId;
this->nThreadIdx = tem.nThreadIdx;
this->nWorkIdx = tem.nWorkIdx;
this->nCpu_start_Idx = tem.nCpu_start_Idx;
this->nCpu_num = tem.nCpu_num;
this->bSaveCheckImg = tem.bSaveCheckImg;
this->flag1 = tem.flag1;
this->flag2 = tem.flag2;
this->bRetest = tem.bRetest;
this->str1 = tem.str1;
this->str2 = tem.str2;
}
};
/*******************一般调用流程*************************************************************************************************************************/
/*******************1、初始化 UpdateConfig*************************************************************************************************************************/
/*******************2、初始化 Init 并开启 *************************************************************************************************************************/
/*******************3、GetStatus 获取状态 如果 =CHECK_THREAD_STATUS_IDLE 可以设置检测数据并开启检测 SetDataRun***************************************************/
/*******************4、GetStatus 获取状态 如果 =CHECK_THREAD_STATUS_COMPLETE 检测完成,可以获取检测结果 GetCheckReuslt 拷贝检测结果 自动把状态设为 CHECK_THREAD_STATUS_IDLE*****************************/
struct shareImage;
struct CheckResult;
class ALLImgCheckBase
{
protected:
ALLImgCheckBase() {}
public:
// delete camera interface
~ALLImgCheckBase() {}
static ALLImgCheckBase *GetInstance();
// 初始化参数 pconfig 参数指针 返回0 成功 其他异常
virtual int RunStart(void *pconfig1 = NULL) = 0;
// 设置检测数据,并开启检测 返回0 成功 其他异常
virtual int SetDataRun_SharePtr(std::shared_ptr<shareImage> p) = 0;
// 获取结果信息 返回0 成功 其他异常
virtual int GetCheckReuslt(std::shared_ptr<CheckResult> &pResult) = 0;
virtual int CheckImg(std::shared_ptr<shareImage> p, std::shared_ptr<CheckResult> &pResult) = 0;
// 获取检测库 状态信息 返回CHECK_THREAD_RUN_STATUS
virtual int GetStatus() = 0;
// 更新参数 pconfig 参数指针nConfigType 需要更新的参数类型 返回0 成功 其他异常
virtual int UpdateConfig(void *pconfig, int nConfigType) = 0;
// 返回检测版本信息
virtual std::string GetVersion() = 0;
// 返回错误信息
virtual std::string GetErrorInfo() = 0;
static ALLImgCheckBase *instance;
};
#endif