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.

143 lines
5.5 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 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
};
struct RunInfoST
{
int nThreadIdx; // 线程号id
int nDeviceId; // GPU 设备 号 0 或 1
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;
nCpu_start_Idx = 0;
nCpu_num = 8;
flag1 = 0;
flag2 = 0;
bRetest = false;
str1 = "";
str2 = "";
bSaveCheckImg = false;
}
void copy(RunInfoST tem)
{
this->nDeviceId = tem.nDeviceId;
this->nThreadIdx = tem.nThreadIdx;
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;
}
};
/*******************更新参数回传结构***********************************************************************************************************************/
// 说明: 更新参数(UpdateConfig / 检测前更新参数)时, 算法侧把从 json 读到的参数值填进本结构体,
// 再通过接口返回给调用方。需要回传的字段直接往这里加即可。
struct flaw_info
{
float area; // 缺陷面积
float gray_dis; // 缺陷灰阶
flaw_info()
{
area = 0.0f;
gray_dis = 0.0f;
}
void copy(flaw_info tem)
{
this->area = tem.area;
this->gray_dis = tem.gray_dis;
}
};
struct UpdateParamOutST
{
float pixel_precision_x; // x成像检测精度
float pixel_precision_y; // y成像检测精度
flaw_info aotudian; // 凹凸点参数
flaw_info zangwu; // 脏污参数
flaw_info line; // 线状参数
flaw_info dianzhuang; // 点状参数
flaw_info xianwei; // 纤维参数
flaw_info posun; // 破损参数
UpdateParamOutST()
{
pixel_precision_x = 0.0f;
pixel_precision_y = 0.0f;
}
void copy(UpdateParamOutST tem)
{
this->pixel_precision_x = tem.pixel_precision_x;
this->pixel_precision_y = tem.pixel_precision_y;
this->aotudian.copy(tem.aotudian);
this->zangwu.copy(tem.zangwu);
this->line.copy(tem.line);
this->dianzhuang.copy(tem.dianzhuang);
this->xianwei.copy(tem.xianwei);
this->posun.copy(tem.posun);
}
};
/*******************一般调用流程*************************************************************************************************************************/
/*******************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;
// 获取指定相机在更新参数后回传的参数值(strCamera 为相机名) 返回0 成功 其他异常
virtual int GetUpdateParamOut(const std::string &strCamera, UpdateParamOutST &outParam) = 0;
// 返回检测版本信息
virtual std::string GetVersion() = 0;
// 返回错误信息
virtual std::string GetErrorInfo() = 0;
static ALLImgCheckBase *instance;
};
#endif