diff --git a/camera.cpp b/camera.cpp index 54d1abf..b2c38d3 100644 --- a/camera.cpp +++ b/camera.cpp @@ -3,9 +3,9 @@ #include // Debug Options -#define GlobalDebug 1 // 全局是否允许打印Debug信息(打印会拖慢处理时间) +#define GlobalDebug 0 // 全局是否允许打印Debug信息(打印会拖慢处理时间) #define DebugDetection 0 // 注意开启这个编译选项会导致图片存储, 处理时间会很慢 -#define DebugDetectionTime 1 // 是否打印处理时间 +#define DebugDetectionTime 0 // 是否打印处理时间 #define DebugLowerMacCOM 0 // 是否打印和下位机通讯的相关信息 camera::camera() {} @@ -24,7 +24,7 @@ static MIL_ID detection_result0; static MIL_ID MilImage_Onnx0; static MIL_ID ModifiedBufferId0; static MIL_ID MilGrabBufferList0[20] = {0}; -static MIL_INT BufSizeX0 = 4096; +static MIL_INT BufSizeX0 = 2048; static MIL_INT BufSizeY0 = 512; unsigned char* m_AvsBuffer0 = (unsigned char*)malloc(BufSizeX0 * BufSizeY0 * 3); static int FuncCount0 = 1; @@ -36,7 +36,7 @@ static MIL_ID detection_result1; static MIL_ID MilImage_Onnx1; static MIL_ID ModifiedBufferId1; static MIL_ID MilGrabBufferList1[20] = {0}; -static MIL_INT BufSizeX1 = 4096; +static MIL_INT BufSizeX1 = 2048; static MIL_INT BufSizeY1 = 512; unsigned char* m_AvsBuffer1 = (unsigned char*)malloc(BufSizeX1 * BufSizeY1 * 3); static int FuncCount1 = 1; @@ -181,18 +181,18 @@ MIL_INT ProcessingFunction0(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr) // 拷贝艳丽色检测图像 MbufCopy(ModifiedBufferId0, MilImage_Color0); - MIL_UNIQUE_BUF_ID MimResizedestination = MbufAllocColor(MilSystem, 3, 2048, 512, 8+M_UNSIGNED, M_IMAGE+M_PROC+M_DISP, M_UNIQUE_ID); - MbufClear(MimResizedestination, M_COLOR_BLACK); - MimResize(MilImage_Color0, MimResizedestination, 0.5, 1 , M_DEFAULT); + // MIL_UNIQUE_BUF_ID MimResizedestination = MbufAllocColor(MilSystem, 3, 2048, 512, 8+M_UNSIGNED, M_IMAGE+M_PROC+M_DISP, M_UNIQUE_ID); + // MbufClear(MimResizedestination, M_COLOR_BLACK); + // MimResize(MilImage_Color0, MimResizedestination, 0.5, 1 , M_DEFAULT); #if(GlobalDebug && DebugDetectionTime) timer_detection_time.printElapsedTime("CallBack1: High sat detection resize"); timer_detection_time.restart(); #endif // 图片镜像翻转 - MIL_UNIQUE_BUF_ID MimFlipDedtination = MbufClone(MimResizedestination, M_DEFAULT, M_DEFAULT, M_DEFAULT, M_DEFAULT, M_DEFAULT, M_DEFAULT, M_UNIQUE_ID); + 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); - MimFlip(MimResizedestination, MimFlipDedtination, M_FLIP_HORIZONTAL, M_DEFAULT); + MimFlip(MilImage_Color0, MimFlipDedtination, M_FLIP_HORIZONTAL, M_DEFAULT); cv::Mat img = ImageUtils::mil2Mat(MimFlipDedtination); // 将图像推入识别队列 @@ -208,18 +208,39 @@ MIL_INT ProcessingFunction0(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr) timer_detection_time.restart(); #endif - //艳丽检测mask + // 艳丽检测mask + // 修改 high_sat_detect 调用,使用 std::future 限制执行时间 + std::vector> matrox_mask; + if(g_traditional_enable[camera_id]) { - high_sat_detect(MimFlipDedtination, detection_result0, params); + // 使用 std::async 将 high_sat_detect 封装为异步任务 + auto future = std::async(std::launch::async, [&]() { + high_sat_detect(MilImage_Color0, detection_result0, params); + }); + + // 等待最多20毫秒 + if(future.wait_for(std::chrono::milliseconds(30)) == std::future_status::ready) + { +#if(GlobalDebug && DebugDetectionTime) + timer_detection_time.printElapsedTime("CallBack1: High sat detection finish"); + timer_detection_time.restart(); +#endif \ + // 任务在20ms内完成,可以继续使用 detection_result1 \ + // 将 Matrox 的检测结果转换为 二维vector + matrox_mask = generateMaskFromMatImage(ImageUtils::mil2Mat(detection_result0), widthBlocks, heightBlocks, sizeThreshold); + } + else + { + // 任务超时,处理超时情况 + qWarning() << "high_sat_detect 超时,未在20ms内完成。"; + // 创建一个大小为 widthBlocks x heightBlocks 的 matrox_mask + matrox_mask = std::vector>(heightBlocks, std::vector(widthBlocks, 0)); + } } -#if(GlobalDebug && DebugDetectionTime) - timer_detection_time.printElapsedTime("CallBack1: High sat detection finish"); - timer_detection_time.restart(); -#endif - // 将 Matrox 的检测结果转换为 二维vector - std::vector> matrox_mask = generateMaskFromMatImage(ImageUtils::mil2Mat(detection_result0), widthBlocks, heightBlocks, sizeThreshold); + + #if(GlobalDebug && DebugDetectionTime) timer_detection_time.printElapsedTime("CallBack1: High sat detection to mask"); timer_detection_time.restart(); @@ -229,26 +250,35 @@ MIL_INT ProcessingFunction0(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr) std::vector> dl_mask; ImageData dl_data; - if(g_dl_enable[camera_id]) + if (g_dl_enable[camera_id]) { - if(!g_result_Queue[camera_id]->dequeue(dl_data)) + // 使用 std::async 将深度学习检测封装为异步任务 + auto future_dl = std::async(std::launch::async, [&]() -> bool { + // 尝试从队列中获取检测结果,假设 dequeue 支持超时 + // 如果 dequeue 不支持超时,请确保它不会无限期阻塞 + bool success = g_result_Queue[camera_id]->dequeue(dl_data); + return success; + }); + + // 等待最多20毫秒 + if (future_dl.wait_for(std::chrono::milliseconds(30)) == std::future_status::ready && future_dl.get()) { - qWarning() << "CallBack1: Receive empty result from Onnx for camera" << camera_id; - // 如果没有深度学习的检测结果,使用 Matrox 的检测结果 - dl_mask = matrox_mask; - merged_mask = matrox_mask; #if(GlobalDebug && DebugDetectionTime) - timer_detection_time.printElapsedTime("CallBack1: DL detection error to mask"); + timer_detection_time.printElapsedTime("CallBack1: DL detection finished within 20ms"); timer_detection_time.restart(); #endif - } - else - { // 将深度学习的检测结果转换为 OpenCV Mat dl_mask = generateMaskFromMatImage(dl_data.image, widthBlocks, heightBlocks, sizeThreshold); merged_mask = ImageUtils::mergeMasks(dl_mask, matrox_mask); + } + else + { + // 任务超时或未成功获取结果,使用 Matrox 的检测结果 + qWarning() << "DL detection 超时或未成功获取结果 for camera" << camera_id; + dl_mask = matrox_mask; + merged_mask = matrox_mask; #if(GlobalDebug && DebugDetectionTime) - timer_detection_time.printElapsedTime("CallBack2: Wait DL detection and result to mask"); + timer_detection_time.printElapsedTime("CallBack1: DL detection error or timeout to mask"); timer_detection_time.restart(); #endif } @@ -258,13 +288,15 @@ MIL_INT ProcessingFunction0(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr) dl_mask = matrox_mask; merged_mask = matrox_mask; } - // Update the current Img MIl id - // 更新持久化存储 - // { - // QMutexLocker locker(&g_detection_result[camera_id].mutex); - // g_detection_result[camera_id].dl_mask = dl_mask; - // g_detection_result[camera_id].traditional_mask = matrox_mask; - // } + + +// Update the current Img MIl id +// 更新持久化存储 +// { +// QMutexLocker locker(&g_detection_result[camera_id].mutex); +// g_detection_result[camera_id].dl_mask = dl_mask; +// g_detection_result[camera_id].traditional_mask = matrox_mask; +// } #if(GlobalDebug && DebugDetectionTime) timer_detection_time.printElapsedTime("CallBack1: Push result to g_detection_result"); timer_detection_time.restart(); @@ -319,9 +351,9 @@ MIL_INT ProcessingFunction1(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr) //拷贝艳丽色检测图像 MbufCopy(ModifiedBufferId1,MilImage_Color1); - MIL_UNIQUE_BUF_ID MimResizedestination = MbufAllocColor(MilSystem, 3, 2048, 512, 8+M_UNSIGNED, M_IMAGE+M_PROC+M_DISP, M_UNIQUE_ID); - MbufClear(MimResizedestination, M_COLOR_BLACK); - MimResize(MilImage_Color1, MimResizedestination, 0.5, 1 , M_DEFAULT); + // MIL_UNIQUE_BUF_ID MimResizedestination = MbufAllocColor(MilSystem, 3, 2048, 512, 8+M_UNSIGNED, M_IMAGE+M_PROC+M_DISP, M_UNIQUE_ID); + // MbufClear(MimResizedestination, M_COLOR_BLACK); + // MimResize(MilImage_Color1, MimResizedestination, 0.5, 1 , M_DEFAULT); #if(GlobalDebug && DebugDetectionTime) timer_detection_time.printElapsedTime("CallBack2: High sat detection resize"); @@ -331,7 +363,7 @@ MIL_INT ProcessingFunction1(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr) if(g_dl_enable[camera_id]) { // 将图像推入识别队列 - cv::Mat img = ImageUtils::mil2Mat(MimResizedestination); + cv::Mat img = ImageUtils::mil2Mat(MilImage_Color1); ImageData recognitionData; recognitionData.camera_id = 1; recognitionData.image = img; @@ -343,18 +375,44 @@ MIL_INT ProcessingFunction1(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr) #endif // 艳丽检测mask + // 修改 high_sat_detect 调用,使用 std::future 限制执行时间 + std::vector> matrox_mask; + if(g_traditional_enable[camera_id]) { - high_sat_detect(MimResizedestination, detection_result1, params); + // 使用 std::async 将 high_sat_detect 封装为异步任务 + auto future = std::async(std::launch::async, [&]() { + high_sat_detect(MilImage_Color1, detection_result1, params); + }); + + // 等待最多20毫秒 + if(future.wait_for(std::chrono::milliseconds(30)) == std::future_status::ready) + { +#if(GlobalDebug && DebugDetectionTime) + timer_detection_time.printElapsedTime("CallBack2: High sat detection finish"); + timer_detection_time.restart(); +#endif + // 任务在20ms内完成,可以继续使用 detection_result1 \ + // 将 Matrox 的检测结果转换为 二维vector + matrox_mask = generateMaskFromMatImage(ImageUtils::mil2Mat(detection_result1), widthBlocks, heightBlocks, sizeThreshold); + } + else + { +#if(GlobalDebug && DebugDetectionTime) + timer_detection_time.printElapsedTime("CallBack2: High sat detection timeout"); + timer_detection_time.restart(); +#endif + // 任务超时,处理超时情况 + qWarning() << "high_sat_detect 超时,未在20ms内完成。"; + // 创建一个大小为 widthBlocks x heightBlocks 的 matrox_mask + matrox_mask = std::vector>(heightBlocks, std::vector(widthBlocks, 0)); + } } -#if(GlobalDebug && DebugDetectionTime) - timer_detection_time.printElapsedTime("CallBack2: High sat detection finish"); - timer_detection_time.restart(); -#endif - // 将 Matrox 的检测结果转换为 二维vector - std::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(); @@ -364,37 +422,49 @@ MIL_INT ProcessingFunction1(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr) std::vector> merged_mask; std::vector> dl_mask; ImageData dl_data; - if(g_dl_enable[camera_id]) + + if (g_dl_enable[camera_id]) { - if(!g_result_Queue[camera_id]->dequeue(dl_data)) + // 使用 std::async 将深度学习检测封装为异步任务 + auto future_dl = std::async(std::launch::async, [&]() -> bool { + // 尝试从队列中获取检测结果,假设 dequeue 支持超时 + // 如果 dequeue 不支持超时,请确保它不会无限期阻塞 + bool success = g_result_Queue[camera_id]->dequeue(dl_data); + return success; + }); + + // 等待最多20毫秒 + if (future_dl.wait_for(std::chrono::milliseconds(30)) == std::future_status::ready && future_dl.get()) { - qWarning() << "Receive empty result from Onnx for camera" << camera_id; - // 如果没有深度学习的检测结果,使用 Matrox 的检测结果 - dl_mask = matrox_mask; - merged_mask = matrox_mask; #if(GlobalDebug && DebugDetectionTime) - timer_detection_time.printElapsedTime("CallBack1: DL detection error to mask"); + timer_detection_time.printElapsedTime("CallBack1: DL detection finished within 20ms"); timer_detection_time.restart(); #endif + // 将深度学习的检测结果转换为 OpenCV Mat + dl_mask = generateMaskFromMatImage(dl_data.image, widthBlocks, heightBlocks, sizeThreshold); + merged_mask = ImageUtils::mergeMasks(dl_mask, matrox_mask); } else { - // 将深度学习的检测结果转换为 OpenCV Mat - dl_mask = generateMaskFromMatImage(dl_data.image, widthBlocks, heightBlocks, sizeThreshold); - merged_mask = ImageUtils::mergeMasks(dl_mask, matrox_mask); + // 任务超时或未成功获取结果,使用 Matrox 的检测结果 + qWarning() << "DL detection 超时或未成功获取结果 for camera" << camera_id; + dl_mask = matrox_mask; + merged_mask = matrox_mask; #if(GlobalDebug && DebugDetectionTime) - timer_detection_time.printElapsedTime("CallBack1: Wait DL detection and result to mask"); + timer_detection_time.printElapsedTime("CallBack1: DL detection error or timeout to mask"); timer_detection_time.restart(); #endif } - }else + } + else { dl_mask = matrox_mask; merged_mask = matrox_mask; } - // Update the current Img MIl id - // 更新持久化存储 + +// Update the current Img MIl id +// 更新持久化存储 #if(GlobalDebug && DebugDetectionTime) timer_detection_time.printElapsedTime("CallBack2: Push result to g_detection_result"); timer_detection_time.restart(); diff --git a/camera.h b/camera.h index 3a5a52d..df0864a 100644 --- a/camera.h +++ b/camera.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include diff --git a/config/1.dcf b/config/1.dcf index 46ce0be..4fedc71 100644 --- a/config/1.dcf +++ b/config/1.dcf @@ -21,12 +21,13 @@ / / / +/ [CAMERA_NAME] no name [CONFIG_FILE] 50CF ODYSSEY -Mon Dec 16 12:30:58 2024 +Wed Dec 25 13:24:12 2024 [INFO_FILE_REV] 0010.0019.0000 RADIENT/eVCL/DUAL @@ -68,7 +69,7 @@ VDC_IN_CH1 VDC_IN_CH2 0x0 VDC_IN_CH3 0x0 VDC_IN_CH_C 0x0 -VDC_DIGITIZER 0x1 +VDC_DIGITIZER 0x0 VDC_PSG_MODE_1_CHECK 0x1 VDC_PSG_MODE_2_CHECKS 0x0 VDC_PSG_MODE_3_CHECKS 0x0 @@ -117,9 +118,9 @@ VDT_NOVERT VDT_HSYNC 0x0 VDT_HBPORCH 0x10 VDT_HFPORCH 0x0 -VDT_HACTIVE 0x1000 -VDT_HTOTAL 0x1010 -VDT_HSYNC_FREQ 0x4bff +VDT_HACTIVE 0x800 +VDT_HTOTAL 0x810 +VDT_HSYNC_FREQ 0x9767 VDT_VSYNC 0x0 VDT_VBPORCH 0x0 VDT_VFPORCH 0x0 @@ -1562,8 +1563,8 @@ DEF_INFO_XSIZE_DIVISOR DEF_INFO_YSIZE_DIVISOR 0x1 DEF_ADD_HACTIVE_MULTIPLEX 0x0 DEF_ADD_VACTIVE_MULTIPLEX 0x0 -DEF_HTOTAL_ENTRY 0x1010 -DEF_HACTIVE_ENTRY 0x1000 +DEF_HTOTAL_ENTRY 0x810 +DEF_HACTIVE_ENTRY 0x800 DEF_VTOTAL_ENTRY 0x200 DEF_VACTIVE_ENTRY 0x200 DEF_CL_NEW_HCROPPING 0x10 @@ -1585,7 +1586,7 @@ DEF_ADD_3MAX_TOTAL_HVBLANK_ZERO DEF_ADD_HTOTAL_EQUA_HEVAL 0x0 DEF_HOR_COUNT_MAX_BITWISE 0xffff DEF_VERT_COUNT_MAX_BITWISE 0xffff -DEF_DIG_HTOTAL 0x100f +DEF_DIG_HTOTAL 0x80f DEF_DIG_VTOTAL 0x1ff DEF_TEST_MODE_HFP_MIN 0x0 DEF_TEST_MODE_HSY_HBP_MIN_CL 0x0 @@ -1616,8 +1617,8 @@ DEF_TIMER0_PIPE_DELAY1 DEF_TIMER1_PIPE_DELAY1 0x0 DEF_TMR0_CLKTMR1_CNT 0x0 DEF_TMR1_CLKTMR0_CNT 0x0 -DEF_TIMER01_CLK_HS_FREQ 0x4c03 -DEF_TIMER01_CLK_HS_PERIOD 0xc8be +DEF_TIMER01_CLK_HS_FREQ 0x977a +DEF_TIMER01_CLK_HS_PERIOD 0x64bc DEF_TIMER0_CLK_HS_PERIOD_DLY1_CNT 0x0 DEF_TIMER0_CLK_HS_PERIOD_DLY2_CNT 0x0 DEF_TIMER0_CLK_HS_PERIOD_T1_CNT 0x0 @@ -1732,7 +1733,7 @@ DEF_DIG1_BYTESORDER [REG_DIGIT] INFO_CUSTOM 0x0 INFO_REGISTER_REV 0x1 -INFO_XSIZE 0x1000 +INFO_XSIZE 0x800 INFO_YSIZE 0x200 INFO_TYPE 0x1 INFO_BAYER 0x0 @@ -1926,13 +1927,13 @@ INFO_MASK_T2CTLH INFO_MASK_T3CTLL 0x0 INFO_MASK_T3CTLH 0x0 DIG_HCNT 0x1 -DIG_HTOTAL 0x100f +DIG_HTOTAL 0x80f DIG_HSCNT 0x0 DIG_HECNT 0x1 DIG_HSSYNC 0x0 DIG_HESYNC 0x0 DIG_HSVAL 0x10 -DIG_HEVAL 0x100f +DIG_HEVAL 0x80f DIG_HSCLM 0x0 DIG_HECLM 0x0 DIG_HCTL 0x1e0 @@ -2352,5 +2353,5 @@ DIG_IOCTL1H DIG_IOCTL0_L not_modified DIG_ENCTL not_modified [EOF] -00007FF7D438AAA8 0x400c8 -00007FF7D438AA90 0x3942cb8e \ No newline at end of file +00007FF726A5AAA8 0x400c3 +00007FF726A5AA90 0x76edfd9e \ No newline at end of file diff --git a/config/2.dcf b/config/2.dcf index d0bb38f..bc7b103 100644 --- a/config/2.dcf +++ b/config/2.dcf @@ -19,12 +19,13 @@ / / / +/ [CAMERA_NAME] no name [CONFIG_FILE] 50CF ODYSSEY -Mon Dec 23 11:31:47 2024 +Wed Dec 25 13:24:25 2024 [INFO_FILE_REV] 0010.0019.0000 RADIENT/eVCL/DUAL @@ -66,7 +67,7 @@ VDC_IN_CH1 VDC_IN_CH2 0x0 VDC_IN_CH3 0x0 VDC_IN_CH_C 0x0 -VDC_DIGITIZER 0x1 +VDC_DIGITIZER 0x0 VDC_PSG_MODE_1_CHECK 0x1 VDC_PSG_MODE_2_CHECKS 0x0 VDC_PSG_MODE_3_CHECKS 0x0 @@ -115,9 +116,9 @@ VDT_NOVERT VDT_HSYNC 0x0 VDT_HBPORCH 0x10 VDT_HFPORCH 0x0 -VDT_HACTIVE 0x1000 -VDT_HTOTAL 0x1010 -VDT_HSYNC_FREQ 0x4bff +VDT_HACTIVE 0x800 +VDT_HTOTAL 0x810 +VDT_HSYNC_FREQ 0x9767 VDT_VSYNC 0x0 VDT_VBPORCH 0x0 VDT_VFPORCH 0x0 @@ -1560,8 +1561,8 @@ DEF_INFO_XSIZE_DIVISOR DEF_INFO_YSIZE_DIVISOR 0x1 DEF_ADD_HACTIVE_MULTIPLEX 0x0 DEF_ADD_VACTIVE_MULTIPLEX 0x0 -DEF_HTOTAL_ENTRY 0x1010 -DEF_HACTIVE_ENTRY 0x1000 +DEF_HTOTAL_ENTRY 0x810 +DEF_HACTIVE_ENTRY 0x800 DEF_VTOTAL_ENTRY 0x200 DEF_VACTIVE_ENTRY 0x200 DEF_CL_NEW_HCROPPING 0x10 @@ -1583,7 +1584,7 @@ DEF_ADD_3MAX_TOTAL_HVBLANK_ZERO DEF_ADD_HTOTAL_EQUA_HEVAL 0x0 DEF_HOR_COUNT_MAX_BITWISE 0xffff DEF_VERT_COUNT_MAX_BITWISE 0xffff -DEF_DIG_HTOTAL 0x100f +DEF_DIG_HTOTAL 0x80f DEF_DIG_VTOTAL 0x1ff DEF_TEST_MODE_HFP_MIN 0x0 DEF_TEST_MODE_HSY_HBP_MIN_CL 0x0 @@ -1614,8 +1615,8 @@ DEF_TIMER0_PIPE_DELAY1 DEF_TIMER1_PIPE_DELAY1 0x0 DEF_TMR0_CLKTMR1_CNT 0x0 DEF_TMR1_CLKTMR0_CNT 0x0 -DEF_TIMER01_CLK_HS_FREQ 0x4c03 -DEF_TIMER01_CLK_HS_PERIOD 0xc8be +DEF_TIMER01_CLK_HS_FREQ 0x977a +DEF_TIMER01_CLK_HS_PERIOD 0x64bc DEF_TIMER0_CLK_HS_PERIOD_DLY1_CNT 0x0 DEF_TIMER0_CLK_HS_PERIOD_DLY2_CNT 0x0 DEF_TIMER0_CLK_HS_PERIOD_T1_CNT 0x0 @@ -1730,7 +1731,7 @@ DEF_DIG1_BYTESORDER [REG_DIGIT] INFO_CUSTOM 0x0 INFO_REGISTER_REV 0x1 -INFO_XSIZE 0x1000 +INFO_XSIZE 0x800 INFO_YSIZE 0x200 INFO_TYPE 0x1 INFO_BAYER 0x0 @@ -1924,13 +1925,13 @@ INFO_MASK_T2CTLH INFO_MASK_T3CTLL 0x0 INFO_MASK_T3CTLH 0x0 DIG_HCNT 0x1 -DIG_HTOTAL 0x100f +DIG_HTOTAL 0x80f DIG_HSCNT 0x0 DIG_HECNT 0x1 DIG_HSSYNC 0x0 DIG_HESYNC 0x0 DIG_HSVAL 0x10 -DIG_HEVAL 0x100f +DIG_HEVAL 0x80f DIG_HSCLM 0x0 DIG_HECLM 0x0 DIG_HCTL 0x1e0 @@ -2350,5 +2351,5 @@ DIG_IOCTL1H DIG_IOCTL0_L not_modified DIG_ENCTL not_modified [EOF] -00007FF72205AAA8 0x400c2 -00007FF72205AA90 0x48b9cbd0 \ No newline at end of file +00007FF726A5AAA8 0x400bd +00007FF726A5AA90 0x5616b879 \ No newline at end of file diff --git a/main.cpp b/main.cpp index 740c65d..f672255 100644 --- a/main.cpp +++ b/main.cpp @@ -1,7 +1,23 @@ #include "widget.h" #include +#include +// 全局变量存储原始的消息处理器 +QtMessageHandler originalHandler = nullptr; + +// 自定义消息处理器 +void customMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) +{ + // 过滤掉特定的警告信息 + if (msg.contains("QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread")) { + return; // 不做任何处理,相当于抑制该消息 + } + // 其他消息交给原始处理器 + if (originalHandler) { + originalHandler(type, context, msg); + } +} int main(int argc, char *argv[]) { @@ -12,6 +28,10 @@ int main(int argc, char *argv[]) // } QApplication a(argc, argv); + + // 安装自定义消息处理器,保存原始处理器 + originalHandler = qInstallMessageHandler(customMessageHandler); + Widget w; w.show(); return a.exec(); diff --git a/release/config/1.dcf b/release/config/1.dcf index 46ce0be..4fedc71 100644 --- a/release/config/1.dcf +++ b/release/config/1.dcf @@ -21,12 +21,13 @@ / / / +/ [CAMERA_NAME] no name [CONFIG_FILE] 50CF ODYSSEY -Mon Dec 16 12:30:58 2024 +Wed Dec 25 13:24:12 2024 [INFO_FILE_REV] 0010.0019.0000 RADIENT/eVCL/DUAL @@ -68,7 +69,7 @@ VDC_IN_CH1 VDC_IN_CH2 0x0 VDC_IN_CH3 0x0 VDC_IN_CH_C 0x0 -VDC_DIGITIZER 0x1 +VDC_DIGITIZER 0x0 VDC_PSG_MODE_1_CHECK 0x1 VDC_PSG_MODE_2_CHECKS 0x0 VDC_PSG_MODE_3_CHECKS 0x0 @@ -117,9 +118,9 @@ VDT_NOVERT VDT_HSYNC 0x0 VDT_HBPORCH 0x10 VDT_HFPORCH 0x0 -VDT_HACTIVE 0x1000 -VDT_HTOTAL 0x1010 -VDT_HSYNC_FREQ 0x4bff +VDT_HACTIVE 0x800 +VDT_HTOTAL 0x810 +VDT_HSYNC_FREQ 0x9767 VDT_VSYNC 0x0 VDT_VBPORCH 0x0 VDT_VFPORCH 0x0 @@ -1562,8 +1563,8 @@ DEF_INFO_XSIZE_DIVISOR DEF_INFO_YSIZE_DIVISOR 0x1 DEF_ADD_HACTIVE_MULTIPLEX 0x0 DEF_ADD_VACTIVE_MULTIPLEX 0x0 -DEF_HTOTAL_ENTRY 0x1010 -DEF_HACTIVE_ENTRY 0x1000 +DEF_HTOTAL_ENTRY 0x810 +DEF_HACTIVE_ENTRY 0x800 DEF_VTOTAL_ENTRY 0x200 DEF_VACTIVE_ENTRY 0x200 DEF_CL_NEW_HCROPPING 0x10 @@ -1585,7 +1586,7 @@ DEF_ADD_3MAX_TOTAL_HVBLANK_ZERO DEF_ADD_HTOTAL_EQUA_HEVAL 0x0 DEF_HOR_COUNT_MAX_BITWISE 0xffff DEF_VERT_COUNT_MAX_BITWISE 0xffff -DEF_DIG_HTOTAL 0x100f +DEF_DIG_HTOTAL 0x80f DEF_DIG_VTOTAL 0x1ff DEF_TEST_MODE_HFP_MIN 0x0 DEF_TEST_MODE_HSY_HBP_MIN_CL 0x0 @@ -1616,8 +1617,8 @@ DEF_TIMER0_PIPE_DELAY1 DEF_TIMER1_PIPE_DELAY1 0x0 DEF_TMR0_CLKTMR1_CNT 0x0 DEF_TMR1_CLKTMR0_CNT 0x0 -DEF_TIMER01_CLK_HS_FREQ 0x4c03 -DEF_TIMER01_CLK_HS_PERIOD 0xc8be +DEF_TIMER01_CLK_HS_FREQ 0x977a +DEF_TIMER01_CLK_HS_PERIOD 0x64bc DEF_TIMER0_CLK_HS_PERIOD_DLY1_CNT 0x0 DEF_TIMER0_CLK_HS_PERIOD_DLY2_CNT 0x0 DEF_TIMER0_CLK_HS_PERIOD_T1_CNT 0x0 @@ -1732,7 +1733,7 @@ DEF_DIG1_BYTESORDER [REG_DIGIT] INFO_CUSTOM 0x0 INFO_REGISTER_REV 0x1 -INFO_XSIZE 0x1000 +INFO_XSIZE 0x800 INFO_YSIZE 0x200 INFO_TYPE 0x1 INFO_BAYER 0x0 @@ -1926,13 +1927,13 @@ INFO_MASK_T2CTLH INFO_MASK_T3CTLL 0x0 INFO_MASK_T3CTLH 0x0 DIG_HCNT 0x1 -DIG_HTOTAL 0x100f +DIG_HTOTAL 0x80f DIG_HSCNT 0x0 DIG_HECNT 0x1 DIG_HSSYNC 0x0 DIG_HESYNC 0x0 DIG_HSVAL 0x10 -DIG_HEVAL 0x100f +DIG_HEVAL 0x80f DIG_HSCLM 0x0 DIG_HECLM 0x0 DIG_HCTL 0x1e0 @@ -2352,5 +2353,5 @@ DIG_IOCTL1H DIG_IOCTL0_L not_modified DIG_ENCTL not_modified [EOF] -00007FF7D438AAA8 0x400c8 -00007FF7D438AA90 0x3942cb8e \ No newline at end of file +00007FF726A5AAA8 0x400c3 +00007FF726A5AA90 0x76edfd9e \ No newline at end of file diff --git a/release/config/2.dcf b/release/config/2.dcf index d0bb38f..bc7b103 100644 --- a/release/config/2.dcf +++ b/release/config/2.dcf @@ -19,12 +19,13 @@ / / / +/ [CAMERA_NAME] no name [CONFIG_FILE] 50CF ODYSSEY -Mon Dec 23 11:31:47 2024 +Wed Dec 25 13:24:25 2024 [INFO_FILE_REV] 0010.0019.0000 RADIENT/eVCL/DUAL @@ -66,7 +67,7 @@ VDC_IN_CH1 VDC_IN_CH2 0x0 VDC_IN_CH3 0x0 VDC_IN_CH_C 0x0 -VDC_DIGITIZER 0x1 +VDC_DIGITIZER 0x0 VDC_PSG_MODE_1_CHECK 0x1 VDC_PSG_MODE_2_CHECKS 0x0 VDC_PSG_MODE_3_CHECKS 0x0 @@ -115,9 +116,9 @@ VDT_NOVERT VDT_HSYNC 0x0 VDT_HBPORCH 0x10 VDT_HFPORCH 0x0 -VDT_HACTIVE 0x1000 -VDT_HTOTAL 0x1010 -VDT_HSYNC_FREQ 0x4bff +VDT_HACTIVE 0x800 +VDT_HTOTAL 0x810 +VDT_HSYNC_FREQ 0x9767 VDT_VSYNC 0x0 VDT_VBPORCH 0x0 VDT_VFPORCH 0x0 @@ -1560,8 +1561,8 @@ DEF_INFO_XSIZE_DIVISOR DEF_INFO_YSIZE_DIVISOR 0x1 DEF_ADD_HACTIVE_MULTIPLEX 0x0 DEF_ADD_VACTIVE_MULTIPLEX 0x0 -DEF_HTOTAL_ENTRY 0x1010 -DEF_HACTIVE_ENTRY 0x1000 +DEF_HTOTAL_ENTRY 0x810 +DEF_HACTIVE_ENTRY 0x800 DEF_VTOTAL_ENTRY 0x200 DEF_VACTIVE_ENTRY 0x200 DEF_CL_NEW_HCROPPING 0x10 @@ -1583,7 +1584,7 @@ DEF_ADD_3MAX_TOTAL_HVBLANK_ZERO DEF_ADD_HTOTAL_EQUA_HEVAL 0x0 DEF_HOR_COUNT_MAX_BITWISE 0xffff DEF_VERT_COUNT_MAX_BITWISE 0xffff -DEF_DIG_HTOTAL 0x100f +DEF_DIG_HTOTAL 0x80f DEF_DIG_VTOTAL 0x1ff DEF_TEST_MODE_HFP_MIN 0x0 DEF_TEST_MODE_HSY_HBP_MIN_CL 0x0 @@ -1614,8 +1615,8 @@ DEF_TIMER0_PIPE_DELAY1 DEF_TIMER1_PIPE_DELAY1 0x0 DEF_TMR0_CLKTMR1_CNT 0x0 DEF_TMR1_CLKTMR0_CNT 0x0 -DEF_TIMER01_CLK_HS_FREQ 0x4c03 -DEF_TIMER01_CLK_HS_PERIOD 0xc8be +DEF_TIMER01_CLK_HS_FREQ 0x977a +DEF_TIMER01_CLK_HS_PERIOD 0x64bc DEF_TIMER0_CLK_HS_PERIOD_DLY1_CNT 0x0 DEF_TIMER0_CLK_HS_PERIOD_DLY2_CNT 0x0 DEF_TIMER0_CLK_HS_PERIOD_T1_CNT 0x0 @@ -1730,7 +1731,7 @@ DEF_DIG1_BYTESORDER [REG_DIGIT] INFO_CUSTOM 0x0 INFO_REGISTER_REV 0x1 -INFO_XSIZE 0x1000 +INFO_XSIZE 0x800 INFO_YSIZE 0x200 INFO_TYPE 0x1 INFO_BAYER 0x0 @@ -1924,13 +1925,13 @@ INFO_MASK_T2CTLH INFO_MASK_T3CTLL 0x0 INFO_MASK_T3CTLH 0x0 DIG_HCNT 0x1 -DIG_HTOTAL 0x100f +DIG_HTOTAL 0x80f DIG_HSCNT 0x0 DIG_HECNT 0x1 DIG_HSSYNC 0x0 DIG_HESYNC 0x0 DIG_HSVAL 0x10 -DIG_HEVAL 0x100f +DIG_HEVAL 0x80f DIG_HSCLM 0x0 DIG_HECLM 0x0 DIG_HCTL 0x1e0 @@ -2350,5 +2351,5 @@ DIG_IOCTL1H DIG_IOCTL0_L not_modified DIG_ENCTL not_modified [EOF] -00007FF72205AAA8 0x400c2 -00007FF72205AA90 0x48b9cbd0 \ No newline at end of file +00007FF726A5AAA8 0x400bd +00007FF726A5AA90 0x5616b879 \ No newline at end of file diff --git a/widget.cpp b/widget.cpp index 46bb9dc..97978ca 100644 --- a/widget.cpp +++ b/widget.cpp @@ -19,7 +19,7 @@ using namespace std; // 硬编码参数值 -int file_delay = 1270; // 延迟时间(毫秒) +int file_delay = 1050; // 延迟时间(毫秒) int file_encoder = 12000; // 编码器值++ int file_valve = 200; // 阀门通道 @@ -330,6 +330,19 @@ void Widget::on_btn_start_clicked() { g_recognitionRunning[i]->store(true); g_recognitionThread[i] = new std::thread(detectionWorker, i); + + // 获取线程的本地句柄 + HANDLE hThread = static_cast(g_recognitionThread[i]->native_handle()); + + // 设置线程优先级为最高 + if(SetThreadPriority(hThread, THREAD_PRIORITY_HIGHEST)) + { + std::cout << "DL Thread " << i << " set highest thread priority。" << std::endl; + } + else + { + std::cerr << "SET thread " << i << " failed, error code:" << GetLastError() << std::endl; + } } Start_camera(); diff --git a/widget.h b/widget.h index 82df228..76bb28b 100644 --- a/widget.h +++ b/widget.h @@ -1,5 +1,6 @@ #ifndef WIDGET_H #define WIDGET_H +#include #include #include #include