Files
eUi/include/paramSpecifications.h
T
RCiRoot 97462c8aab On main: V20260416-2.5.1
增加halconGuard类,用于防止halcon算法的输入输出和程序不一致而引起的报错,并且会检查算法文件是否存在,如不存在则会弹窗提示。
增加handleAiGpuThreadGuard类,用于防止因重复调用同一个模型而引起的报错,并且支持不停机更新模型,支持初始化时检测模型文件是否存在。
增加内存占用显示控件。
用户管理增加root权限,默认密码为dseuiroot,模型热更新时需要此权限。
支持缓存界面上的检测数据。
相机模块新增在回调后的指定时间没有取图时则清空容器的功能。
增加等待结果汇总功能,在启用时同一个SN的图片会等待总结果后再进行存图。
存图线程修改为多线程编码,单线程储存,提高IO效率。并且增加根据内存占用的百分比更新存图逻辑的功能,默认占用超过70%不储存OK原图,超过80%不储存原图,超过90%时不储存所有图片。
2026-04-26 12:25:13 +08:00

83 lines
3.5 KiB
C++

struct valueControlStruct {
double minThreshold;
double maxThreshold;
bool enable;
};
//生成一个数据的上下限与是否启用
//类名 值名 单位名 默认下限 默认上限 默认是否启用 数据同步类
valueControlStruct genValueControlStruct(QString className,
QString valueName,
QString unitStr,
double basicMaxThreshold,
double basicMinThreshold,
bool basicEnable,
paramSyncManager* sync) {
valueControlStruct r;
r.maxThreshold = sync->get(className, valueName + "上限(" + unitStr + ")", basicMaxThreshold).toDouble();
r.minThreshold = sync->get(className, valueName + "下限(" + unitStr + ")", basicMinThreshold).toDouble();
r.enable = sync->get(className, valueName + "判定启用", basicEnable).toBool();
return r;
}
std::pair<bool, double> getPerfectOutputValue(
double realValue,
double minValue,
double maxValue,
double offsetValue)
{
static thread_local std::mt19937 rng(std::random_device{}());
std::uniform_real_distribution<double> dist(0.0, 0.1); //随机数
if (realValue < minValue) {// 低于下限
if (minValue - realValue <= offsetValue) {// 在补偿范围内
return { true, minValue + dist(rng) };// 返回补偿后的值
}
return { false, realValue }; // 不在在补偿范围内 返回真实值
}
else if (realValue > maxValue) {
if (realValue - maxValue <= offsetValue) {// 在补偿范围内
return { true, maxValue - dist(rng) };// 返回补偿后的值
}
return { false, realValue }; // 不在在补偿范围内 返回真实值
}
return { false, realValue };// 在范围内,无需补偿,返回真实值
}
std::string controlAccuracy(float num, int length) {
std::string resultString = std::to_string(num);
resultString = resultString.substr(0, resultString.find(".") + length + 1);
return resultString;
}
//包含判断结果 输出打印任务 补偿
void valueJudgement(double value, double upThreshold, double downThreshold, double offset,
bool jugementEnable, bool& halconOk, std::string valueDisplayText, std::string valueDanWei, std::string ngText,
cv::Point p, std::vector<std::string>& defects, cvPainter& _cvPainter) {
cv::Scalar color = cv::Scalar(0, 255, 0);
double newValue = getPerfectOutputValue(value, downThreshold, upThreshold, offset).second;
if (newValue > upThreshold || newValue < downThreshold) {
color = cv::Scalar(0, 0, 255);
if (jugementEnable == true) {
halconOk = false;
defects.push_back(ngText);
}
}
_cvPainter.appendPaintJob(valueDisplayText + controlAccuracy(newValue, 4) + valueDanWei, p, color);
}
void valueJudgement(double value, valueControlStruct valueControlStructInput, double offset,
bool& halconOk, std::string valueDisplayText, std::string valueDanWei, std::string ngText,
cv::Point p, std::vector<std::string>& defects, cvPainter& _cvPainter) {
cv::Scalar color = cv::Scalar(0, 255, 0);
double newValue = getPerfectOutputValue(value, valueControlStructInput.minThreshold, valueControlStructInput.maxThreshold, offset).second;
if (newValue > valueControlStructInput.maxThreshold || newValue < valueControlStructInput.minThreshold) {
color = cv::Scalar(0, 0, 255);
if (valueControlStructInput.enable == true) {
halconOk = false;
defects.push_back(ngText);
}
}
_cvPainter.appendPaintJob(valueDisplayText + controlAccuracy(newValue, 4) + valueDanWei, p, color);
}