关闭传统检测算法版本
This commit is contained in:
parent
2894a4d91a
commit
ca3faa5f85
33
camera.cpp
33
camera.cpp
@ -20,8 +20,6 @@ MIL_ID MilSystem;
|
|||||||
static MIL_ID MilDigitizer0;
|
static MIL_ID MilDigitizer0;
|
||||||
static MIL_ID MilImage0;
|
static MIL_ID MilImage0;
|
||||||
static MIL_ID MilImage_Color0;
|
static MIL_ID MilImage_Color0;
|
||||||
static MIL_ID detection_result0;
|
|
||||||
static MIL_ID MilImage_Onnx0;
|
|
||||||
static MIL_ID ModifiedBufferId0;
|
static MIL_ID ModifiedBufferId0;
|
||||||
static MIL_ID MilGrabBufferList0[20] = {0};
|
static MIL_ID MilGrabBufferList0[20] = {0};
|
||||||
static MIL_INT BufSizeX0 = 2048;
|
static MIL_INT BufSizeX0 = 2048;
|
||||||
@ -32,8 +30,6 @@ static int FuncCount0 = 1;
|
|||||||
static MIL_ID MilDigitizer1;
|
static MIL_ID MilDigitizer1;
|
||||||
static MIL_ID MilImage1;
|
static MIL_ID MilImage1;
|
||||||
static MIL_ID MilImage_Color1;
|
static MIL_ID MilImage_Color1;
|
||||||
static MIL_ID detection_result1;
|
|
||||||
static MIL_ID MilImage_Onnx1;
|
|
||||||
static MIL_ID ModifiedBufferId1;
|
static MIL_ID ModifiedBufferId1;
|
||||||
static MIL_ID MilGrabBufferList1[20] = {0};
|
static MIL_ID MilGrabBufferList1[20] = {0};
|
||||||
static MIL_INT BufSizeX1 = 2048;
|
static MIL_INT BufSizeX1 = 2048;
|
||||||
@ -93,10 +89,6 @@ bool iniCamera()
|
|||||||
MbufAllocColor(MilSystem,3,BufSizeX1,BufSizeY1,8 + M_UNSIGNED,M_IMAGE + M_GRAB + M_PROC,&MilImage1);
|
MbufAllocColor(MilSystem,3,BufSizeX1,BufSizeY1,8 + M_UNSIGNED,M_IMAGE + M_GRAB + M_PROC,&MilImage1);
|
||||||
MbufAllocColor(MilSystem,3,BufSizeX0,BufSizeY0,8 + M_UNSIGNED,M_IMAGE + M_GRAB + M_PROC,&MilImage_Color0);
|
MbufAllocColor(MilSystem,3,BufSizeX0,BufSizeY0,8 + M_UNSIGNED,M_IMAGE + M_GRAB + M_PROC,&MilImage_Color0);
|
||||||
MbufAllocColor(MilSystem,3,BufSizeX1,BufSizeY1,8 + M_UNSIGNED,M_IMAGE + M_GRAB + M_PROC,&MilImage_Color1);
|
MbufAllocColor(MilSystem,3,BufSizeX1,BufSizeY1,8 + M_UNSIGNED,M_IMAGE + M_GRAB + M_PROC,&MilImage_Color1);
|
||||||
MbufAllocColor(MilSystem,3,BufSizeX0,BufSizeY0,8 + M_UNSIGNED,M_IMAGE + M_GRAB + M_PROC,&detection_result0);
|
|
||||||
MbufAllocColor(MilSystem,3,BufSizeX1,BufSizeY1,8 + M_UNSIGNED,M_IMAGE + M_GRAB + M_PROC,&detection_result1);
|
|
||||||
MbufAllocColor(MilSystem,3,BufSizeX0,BufSizeY0,8 + M_UNSIGNED,M_IMAGE + M_GRAB + M_PROC,&MilImage_Onnx0);
|
|
||||||
MbufAllocColor(MilSystem,3,BufSizeX1,BufSizeY1,8 + M_UNSIGNED,M_IMAGE + M_GRAB + M_PROC,&MilImage_Onnx1);
|
|
||||||
|
|
||||||
|
|
||||||
//给每一个bufferlist分配空间
|
//给每一个bufferlist分配空间
|
||||||
@ -215,13 +207,16 @@ MIL_INT ProcessingFunction0(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 艳丽检测mask
|
// 艳丽检测mask
|
||||||
|
Mat matrox_mat;
|
||||||
std::vector<std::vector<uint8_t>> matrox_mask;
|
std::vector<std::vector<uint8_t>> matrox_mask;
|
||||||
|
|
||||||
if(g_traditional_enable[camera_id])
|
if(g_traditional_enable[camera_id])
|
||||||
{
|
{
|
||||||
// 使用 std::async 将 high_sat_detect 封装为异步任务
|
// 使用 std::async 将 high_sat_detect 封装为异步任务
|
||||||
auto future = std::async(std::launch::async, [&]() {
|
auto future = std::async(std::launch::async, [&]() {
|
||||||
high_sat_detect(MilImage_Color0, detection_result0, params);
|
MIL_ID detection_result_id;
|
||||||
|
high_sat_detect(MilImage_Color0, detection_result_id, params);
|
||||||
|
matrox_mat = ImageUtils::mil2Mat(detection_result_id);
|
||||||
|
MbufFree(detection_result_id);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 等待最多20毫秒
|
// 等待最多20毫秒
|
||||||
@ -233,7 +228,7 @@ MIL_INT ProcessingFunction0(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr)
|
|||||||
#endif
|
#endif
|
||||||
// 任务在指定时间内完成,可以继续使用 detection_result1 \
|
// 任务在指定时间内完成,可以继续使用 detection_result1 \
|
||||||
// 将 Matrox 的检测结果转换为 二维vector
|
// 将 Matrox 的检测结果转换为 二维vector
|
||||||
matrox_mask = generateMaskFromMatImage(ImageUtils::mil2Mat(detection_result0), widthBlocks, heightBlocks, sizeThreshold);
|
matrox_mask = generateMaskFromMatImage(matrox_mat, widthBlocks, heightBlocks, sizeThreshold);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -309,7 +304,7 @@ MIL_INT ProcessingFunction0(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr)
|
|||||||
#endif
|
#endif
|
||||||
mask_0 = merged_mask;
|
mask_0 = merged_mask;
|
||||||
detection_ready.release();
|
detection_ready.release();
|
||||||
MbufFree(detection_result0);
|
|
||||||
#if(GlobalDebug && DebugDetectionTime)
|
#if(GlobalDebug && DebugDetectionTime)
|
||||||
call_back_timer0.printElapsedTime("CallBack1: Total time spent: ");
|
call_back_timer0.printElapsedTime("CallBack1: Total time spent: ");
|
||||||
#endif
|
#endif
|
||||||
@ -382,13 +377,16 @@ MIL_INT ProcessingFunction1(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 艳丽检测mask
|
// 艳丽检测mask
|
||||||
|
Mat matrox_mat;
|
||||||
std::vector<std::vector<uint8_t>> matrox_mask;
|
std::vector<std::vector<uint8_t>> matrox_mask;
|
||||||
|
|
||||||
if(g_traditional_enable[camera_id])
|
if(g_traditional_enable[camera_id])
|
||||||
{
|
{
|
||||||
// 使用 std::async 将 high_sat_detect 封装为异步任务
|
// 使用 std::async 将 high_sat_detect 封装为异步任务
|
||||||
auto future = std::async(std::launch::async, [&]() {
|
auto future = std::async(std::launch::async, [&]() {
|
||||||
high_sat_detect(MilImage_Color1, detection_result1, params);
|
MIL_ID detection_result_id;
|
||||||
|
high_sat_detect(MilImage_Color0, detection_result_id, params);
|
||||||
|
matrox_mat = ImageUtils::mil2Mat(detection_result_id);
|
||||||
|
MbufFree(detection_result_id);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 等待最多20毫秒
|
// 等待最多20毫秒
|
||||||
@ -400,7 +398,7 @@ MIL_INT ProcessingFunction1(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr)
|
|||||||
#endif
|
#endif
|
||||||
// 任务在20ms内完成,可以继续使用 detection_result1 \
|
// 任务在20ms内完成,可以继续使用 detection_result1 \
|
||||||
// 将 Matrox 的检测结果转换为 二维vector
|
// 将 Matrox 的检测结果转换为 二维vector
|
||||||
matrox_mask = generateMaskFromMatImage(ImageUtils::mil2Mat(detection_result1), widthBlocks, heightBlocks, sizeThreshold);
|
matrox_mask = generateMaskFromMatImage(matrox_mat, widthBlocks, heightBlocks, sizeThreshold);
|
||||||
#if(GlobalDebug && DebugDetectionTime)
|
#if(GlobalDebug && DebugDetectionTime)
|
||||||
timer_detection_time.printElapsedTime("CallBack2: High sat detection to mask");
|
timer_detection_time.printElapsedTime("CallBack2: High sat detection to mask");
|
||||||
timer_detection_time.restart();
|
timer_detection_time.restart();
|
||||||
@ -482,7 +480,7 @@ MIL_INT ProcessingFunction1(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr)
|
|||||||
MbufSave(SAVE_PATH_raw,MilImage_Color0);
|
MbufSave(SAVE_PATH_raw,MilImage_Color0);
|
||||||
MbufSave(SAVE_PATH_result,detection_result0);
|
MbufSave(SAVE_PATH_result,detection_result0);
|
||||||
#endif
|
#endif
|
||||||
|
// 等待另一个算法线程执行结束
|
||||||
detection_ready.acquire();
|
detection_ready.acquire();
|
||||||
|
|
||||||
vector<vector<uint8_t>> mask_tail;
|
vector<vector<uint8_t>> mask_tail;
|
||||||
@ -510,7 +508,6 @@ MIL_INT ProcessingFunction1(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr)
|
|||||||
qWarning()<<"下位机发送失败";
|
qWarning()<<"下位机发送失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
MbufFree(detection_result1);
|
|
||||||
|
|
||||||
#if(GlobalDebug && DebugDetectionTime)
|
#if(GlobalDebug && DebugDetectionTime)
|
||||||
call_back_timer1.printElapsedTime("CallBack2: Total time spent: ");
|
call_back_timer1.printElapsedTime("CallBack2: Total time spent: ");
|
||||||
@ -538,8 +535,6 @@ bool DestoryCamera()
|
|||||||
MbufFree(MilImage1);
|
MbufFree(MilImage1);
|
||||||
MbufFree(MilImage_Color0);
|
MbufFree(MilImage_Color0);
|
||||||
MbufFree(MilImage_Color1);
|
MbufFree(MilImage_Color1);
|
||||||
MbufFree(MilImage_Onnx0);
|
|
||||||
MbufFree(MilImage_Onnx1);
|
|
||||||
MdigFree(MilDigitizer0);
|
MdigFree(MilDigitizer0);
|
||||||
MdigFree(MilDigitizer1);
|
MdigFree(MilDigitizer1);
|
||||||
MsysFree(MilSystem);
|
MsysFree(MilSystem);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user