注释优化和尝试添加禁止版本
This commit is contained in:
parent
a8552c6223
commit
9bfe3ad683
50
camera.cpp
50
camera.cpp
@ -148,11 +148,14 @@ MIL_INT ProcessingFunction0(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr)
|
||||
Timer call_back_timer0;
|
||||
call_back_timer0.restart();
|
||||
#endif
|
||||
|
||||
int camera_id = 0;
|
||||
|
||||
#if(GlobalDebug && DebugDetectionTime)
|
||||
Timer timer_detection_time;
|
||||
timer_detection_time.restart();
|
||||
#endif
|
||||
|
||||
MdigGetHookInfo(HookId, M_MODIFIED_BUFFER + M_BUFFER_ID, &ModifiedBufferId0);
|
||||
{
|
||||
QMutexLocker locker(&gDispPicMutex0);
|
||||
@ -174,6 +177,7 @@ MIL_INT ProcessingFunction0(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr)
|
||||
data.camera_id = 0;
|
||||
data.image = img.clone(); // 确保图像数据被复制
|
||||
g_storageQueue.enqueue(data);
|
||||
|
||||
#if(GlobalDebug && DebugDetectionTime)
|
||||
qDebug() << "CallBack1: push image to storage queue";
|
||||
#endif
|
||||
@ -189,6 +193,7 @@ MIL_INT ProcessingFunction0(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr)
|
||||
timer_detection_time.printElapsedTime("CallBack1: High sat detection resize");
|
||||
timer_detection_time.restart();
|
||||
#endif
|
||||
|
||||
// 图片镜像翻转
|
||||
MIL_UNIQUE_BUF_ID MimFlipDedtination = MbufClone(MilImage_Color0, M_DEFAULT, M_DEFAULT, M_DEFAULT, M_DEFAULT, M_DEFAULT, M_DEFAULT, M_UNIQUE_ID);
|
||||
MbufClear(MimFlipDedtination, M_COLOR_BLACK);
|
||||
@ -203,13 +208,13 @@ MIL_INT ProcessingFunction0(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr)
|
||||
recognitionData.image = img;
|
||||
g_img_Queue[camera_id]->enqueue(recognitionData);
|
||||
}
|
||||
|
||||
#if(GlobalDebug && DebugDetectionTime)
|
||||
timer_detection_time.printElapsedTime("CallBack1: High sat detection mirror and push to DL");
|
||||
timer_detection_time.restart();
|
||||
#endif
|
||||
|
||||
// 艳丽检测mask
|
||||
// 修改 high_sat_detect 调用,使用 std::future 限制执行时间
|
||||
std::vector<std::vector<uint8_t>> matrox_mask;
|
||||
|
||||
if(g_traditional_enable[camera_id])
|
||||
@ -225,21 +230,23 @@ MIL_INT ProcessingFunction0(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr)
|
||||
#if(GlobalDebug && DebugDetectionTime)
|
||||
timer_detection_time.printElapsedTime("CallBack1: High sat detection finish");
|
||||
timer_detection_time.restart();
|
||||
#endif \
|
||||
// 任务在20ms内完成,可以继续使用 detection_result1 \
|
||||
#endif
|
||||
// 任务在指定时间内完成,可以继续使用 detection_result1 \
|
||||
// 将 Matrox 的检测结果转换为 二维vector
|
||||
matrox_mask = generateMaskFromMatImage(ImageUtils::mil2Mat(detection_result0), widthBlocks, heightBlocks, sizeThreshold);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 任务超时,处理超时情况
|
||||
qWarning() << "high_sat_detect 超时,未在20ms内完成。";
|
||||
qWarning() << "high_sat_detect 超时, 未在指定时间内完成。";
|
||||
// 创建一个大小为 widthBlocks x heightBlocks 的 matrox_mask
|
||||
matrox_mask = std::vector<std::vector<uint8_t>>(heightBlocks, std::vector<uint8_t>(widthBlocks, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
matrox_mask = std::vector<std::vector<uint8_t>>(heightBlocks, std::vector<uint8_t>(widthBlocks, 0));
|
||||
}
|
||||
|
||||
#if(GlobalDebug && DebugDetectionTime)
|
||||
timer_detection_time.printElapsedTime("CallBack1: High sat detection to mask");
|
||||
@ -289,7 +296,6 @@ MIL_INT ProcessingFunction0(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr)
|
||||
merged_mask = matrox_mask;
|
||||
}
|
||||
|
||||
|
||||
// Update the current Img MIl id
|
||||
// 更新持久化存储
|
||||
// {
|
||||
@ -369,13 +375,13 @@ MIL_INT ProcessingFunction1(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr)
|
||||
recognitionData.image = img;
|
||||
g_img_Queue[1]->enqueue(recognitionData);
|
||||
}
|
||||
|
||||
#if(GlobalDebug && DebugDetectionTime)
|
||||
timer_detection_time.printElapsedTime("CallBack2: Without mirror and push to DL");
|
||||
timer_detection_time.restart();
|
||||
#endif
|
||||
|
||||
// 艳丽检测mask
|
||||
// 修改 high_sat_detect 调用,使用 std::future 限制执行时间
|
||||
std::vector<std::vector<uint8_t>> matrox_mask;
|
||||
|
||||
if(g_traditional_enable[camera_id])
|
||||
@ -395,6 +401,10 @@ MIL_INT ProcessingFunction1(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr)
|
||||
// 任务在20ms内完成,可以继续使用 detection_result1 \
|
||||
// 将 Matrox 的检测结果转换为 二维vector
|
||||
matrox_mask = generateMaskFromMatImage(ImageUtils::mil2Mat(detection_result1), widthBlocks, heightBlocks, sizeThreshold);
|
||||
#if(GlobalDebug && DebugDetectionTime)
|
||||
timer_detection_time.printElapsedTime("CallBack2: High sat detection to mask");
|
||||
timer_detection_time.restart();
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -403,20 +413,15 @@ MIL_INT ProcessingFunction1(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr)
|
||||
timer_detection_time.restart();
|
||||
#endif
|
||||
// 任务超时,处理超时情况
|
||||
qWarning() << "high_sat_detect 超时,未在20ms内完成。";
|
||||
qWarning() << "high_sat_detect 超时,未在20ms内完成。";
|
||||
// 创建一个大小为 widthBlocks x heightBlocks 的 matrox_mask
|
||||
matrox_mask = std::vector<std::vector<uint8_t>>(heightBlocks, std::vector<uint8_t>(widthBlocks, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if(GlobalDebug && DebugDetectionTime)
|
||||
timer_detection_time.printElapsedTime("CallBack2: High sat detection to mask");
|
||||
timer_detection_time.restart();
|
||||
#endif
|
||||
else
|
||||
{
|
||||
matrox_mask = std::vector<std::vector<uint8_t>>(heightBlocks, std::vector<uint8_t>(widthBlocks, 0));
|
||||
}
|
||||
|
||||
// 获取深度学习的检测结果并进行合并
|
||||
std::vector<std::vector<uint8_t>> merged_mask;
|
||||
@ -484,19 +489,20 @@ MIL_INT ProcessingFunction1(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr)
|
||||
merged_mask = ImageUtils::mergeMasks(mask_0, mask_1, dual_cam_offset_y);
|
||||
std::tie(merged_mask, mask_tail) = ImageUtils::extractROI(merged_mask, 0, 0, widthBlocks, heightBlocks);
|
||||
|
||||
// 发送前的处理
|
||||
// 结果后处理Post Process
|
||||
// 将每个结果左右扩展,扩展半径默认为1
|
||||
auto mask_expaned = expandMaskHorizontally(merged_mask, expansionRaidus);
|
||||
// 将结果的左右补充上0,让物体大小符合要求
|
||||
PadColumns(mask_expaned, padLeft, padRight, 0);
|
||||
//将mask扩展到合适发送的大小
|
||||
std::vector<std::vector<uint8_t>> mask_Total = expandArray(mask_expaned,64);
|
||||
|
||||
// save masks
|
||||
#if(GlobalDebug && DebugDetection)
|
||||
VectorToImg(mask_1,"C:/Users/Pc/Desktop/img/mask" + std::to_string(FuncCount1) + ".bmp");
|
||||
VectorToImg(mask_1,"C:/Users/Pc/Desktop/img/mask_ignored" + std::to_string(FuncCount1) + ".bmp");
|
||||
VectorToImg(mask_Total,"C:/Users/Pc/Desktop/img/mask_expended" + std::to_string(FuncCount1) + ".bmp");
|
||||
#endif \
|
||||
#endif
|
||||
// 发送到下位机
|
||||
bool result_Low = get_valve_data(mask_Total);
|
||||
if(!result_Low)
|
||||
@ -505,6 +511,7 @@ MIL_INT ProcessingFunction1(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr)
|
||||
}
|
||||
|
||||
MbufFree(detection_result1);
|
||||
|
||||
#if(GlobalDebug && DebugDetectionTime)
|
||||
call_back_timer1.printElapsedTime("CallBack2: Total time spent: ");
|
||||
#endif
|
||||
@ -1355,6 +1362,3 @@ std::vector<std::vector<uint8_t>> expandMaskHorizontally(
|
||||
|
||||
return expanded_mask;
|
||||
}
|
||||
|
||||
|
||||
//onnx_Mask
|
||||
|
||||
Loading…
Reference in New Issue
Block a user