diff --git a/README.md b/README.md index e4cf284..81214ac 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,16 @@ Identify the types and quantities of smoke boxes 1、2D模板匹配算法修改 +2、相机采图后至算法使用期间,通讯格式、图像保存等各种规范修改。 + + + + + +遗留冲突问题: + +1、ADModule中有个确认WorkMode问题,怀疑可能是出入库之前要做区别,导致很多相机操作是跟WorkMode有关的。 + SmokeBoxIdentification.cpp中根据STOCK_CHECK_HEAD等关键词,选择哪个相机进行拍照。 diff --git a/runner17/Release/config/camera - 副本.json b/runner17/Release/config/camera - 副本.json new file mode 100644 index 0000000..222db71 --- /dev/null +++ b/runner17/Release/config/camera - 副本.json @@ -0,0 +1,222 @@ +{ + "devices": { + "LP-OCM-R060GC 00J50359918": { + "algorithm": 1, + "algorithm_dll": 1, + "auto_open": false, + "auto_push": true, + "balanceRatio": 1868, + "balanceRatioSelector": 0, + "board_config_file": "", + "board_name": "", + "board_num": 0, + "board_type": 64, + "camera_file": "", + "exposure": 50000, + "folder": "model5\\", + "format": "None", + "frame_rate": 7.400000095367432, + "gain": 1.0052000284194946, + "height": 2048, + "id": 5, + "loop": 1, + "mac_address": "", + "offset_x": 0, + "offset_y": 0, + "param_policy": 2, + "rely_on_camera": "", + "rotation_angle": 90, + "save": 0, + "save_img_suffix": ".JPG", + "savefile_rgb_swapped": false, + "showname": "相机五", + "trigger_source": "Line0", + "type": 140, + "width": 3072, + "zoom": 1 + }, + "LP-OCM-R060GC 00J50359922": { + "algorithm": 1, + "algorithm_dll": 1, + "auto_open": false, + "auto_push": true, + "balanceRatio": 0, + "balanceRatioSelector": 0, + "board_config_file": "", + "board_name": "", + "board_num": 0, + "board_type": 64, + "camera_file": "", + "exposure": 25000, + "folder": "model1\\", + "format": "None", + "frame_rate": 9.3, + "gain": 1, + "height": 2048, + "id": 1, + "loop": 1, + "mac_address": "", + "offset_x": 0, + "offset_y": 0, + "param_policy": 2, + "rely_on_camera": "", + "rotation_angle": 0, + "save": 1, + "save_img_suffix": ".JPG", + "savefile_rgb_swapped": false, + "showname": "相机一", + "trigger_source": "Line0", + "type": 140, + "width": 3072, + "zoom": 1 + }, + "LP-OCM-R060GC 00J50359923": { + "algorithm": 1, + "algorithm_dll": 1, + "auto_open": false, + "auto_push": true, + "balanceRatio": 0, + "balanceRatioSelector": 0, + "board_config_file": "", + "board_name": "", + "board_num": 0, + "board_type": 64, + "camera_file": "", + "exposure": 25000, + "folder": "model4\\", + "format": "None", + "frame_rate": 7.400000095367432, + "gain": 0, + "height": 2048, + "id": 4, + "loop": 1, + "mac_address": "", + "offset_x": 0, + "offset_y": 0, + "param_policy": 2, + "rely_on_camera": "", + "rotation_angle": 0, + "save": 1, + "save_img_suffix": ".JPG", + "savefile_rgb_swapped": false, + "showname": "相机四", + "trigger_source": "Line0", + "type": 140, + "width": 3072, + "zoom": 1 + }, + "LP-OCM-R060GC 00J50359927": { + "algorithm": 1, + "algorithm_dll": 1, + "auto_open": false, + "auto_push": true, + "balanceRatio": 0, + "balanceRatioSelector": 0, + "board_config_file": "", + "board_name": "", + "board_num": 0, + "board_type": 64, + "camera_file": "", + "exposure": 25000, + "folder": "model2\\", + "format": "None", + "frame_rate": 7.400000095367432, + "gain": 0, + "height": 2048, + "id": 2, + "loop": 1, + "mac_address": "", + "offset_x": 0, + "offset_y": 0, + "param_policy": 2, + "rely_on_camera": "", + "rotation_angle": 0, + "save": 1, + "save_img_suffix": ".JPG", + "savefile_rgb_swapped": false, + "showname": "相机二", + "trigger_source": "Line0", + "type": 140, + "width": 3072, + "zoom": 1 + }, + "LP-OCM-R060GC 00J50359938": { + "algorithm": 1, + "algorithm_dll": 1, + "auto_open": false, + "auto_push": true, + "balanceRatio": 0, + "balanceRatioSelector": 0, + "board_config_file": "", + "board_name": "", + "board_num": 0, + "board_type": 64, + "camera_file": "", + "exposure": 25000, + "folder": "model3\\", + "format": "None", + "frame_rate": 7.400000095367432, + "gain": 0, + "height": 2048, + "id": 3, + "loop": 1, + "mac_address": "", + "offset_x": 0, + "offset_y": 0, + "param_policy": 2, + "rely_on_camera": "", + "rotation_angle": 0, + "save": 1, + "save_img_suffix": ".JPG", + "savefile_rgb_swapped": false, + "showname": "相机三", + "trigger_source": "Line0", + "type": 140, + "width": 3072, + "zoom": 1 + }, + "LP-OCM-R060GC 00J50359945": { + "algorithm": 1, + "algorithm_dll": 1, + "auto_open": false, + "auto_push": true, + "balanceRatio": 0, + "balanceRatioSelector": 0, + "board_config_file": "", + "board_name": "", + "board_num": 0, + "board_type": 64, + "camera_file": "", + "exposure": 50000, + "folder": "model6\\", + "format": "None", + "frame_rate": 7.400000095367432, + "gain": 0, + "height": 2048, + "id": 6, + "loop": 1, + "mac_address": "", + "offset_x": 0, + "offset_y": 0, + "param_policy": 2, + "rely_on_camera": "", + "rotation_angle": 270, + "save": 0, + "save_img_suffix": ".JPG", + "savefile_rgb_swapped": false, + "showname": "相机六", + "trigger_source": "Line0", + "type": 140, + "width": 3072, + "zoom": 1 + } + }, + "top": { + "startID": 5, + "endID": 6 + }, + "side": { + "startID": 1, + "endID": 4 + } +} diff --git a/runner17/Release/config/camera.json b/runner17/Release/config/camera.json index 222db71..0702d49 100644 --- a/runner17/Release/config/camera.json +++ b/runner17/Release/config/camera.json @@ -1,222 +1,47 @@ { - "devices": { - "LP-OCM-R060GC 00J50359918": { - "algorithm": 1, - "algorithm_dll": 1, - "auto_open": false, - "auto_push": true, - "balanceRatio": 1868, - "balanceRatioSelector": 0, - "board_config_file": "", - "board_name": "", - "board_num": 0, - "board_type": 64, - "camera_file": "", - "exposure": 50000, - "folder": "model5\\", - "format": "None", - "frame_rate": 7.400000095367432, - "gain": 1.0052000284194946, - "height": 2048, - "id": 5, - "loop": 1, - "mac_address": "", - "offset_x": 0, - "offset_y": 0, - "param_policy": 2, - "rely_on_camera": "", - "rotation_angle": 90, - "save": 0, - "save_img_suffix": ".JPG", - "savefile_rgb_swapped": false, - "showname": "相机五", - "trigger_source": "Line0", - "type": 140, - "width": 3072, - "zoom": 1 - }, - "LP-OCM-R060GC 00J50359922": { - "algorithm": 1, - "algorithm_dll": 1, - "auto_open": false, - "auto_push": true, - "balanceRatio": 0, - "balanceRatioSelector": 0, - "board_config_file": "", - "board_name": "", - "board_num": 0, - "board_type": 64, - "camera_file": "", - "exposure": 25000, - "folder": "model1\\", - "format": "None", - "frame_rate": 9.3, - "gain": 1, - "height": 2048, - "id": 1, - "loop": 1, - "mac_address": "", - "offset_x": 0, - "offset_y": 0, - "param_policy": 2, - "rely_on_camera": "", - "rotation_angle": 0, - "save": 1, - "save_img_suffix": ".JPG", - "savefile_rgb_swapped": false, - "showname": "相机一", - "trigger_source": "Line0", - "type": 140, - "width": 3072, - "zoom": 1 - }, - "LP-OCM-R060GC 00J50359923": { - "algorithm": 1, - "algorithm_dll": 1, - "auto_open": false, - "auto_push": true, - "balanceRatio": 0, - "balanceRatioSelector": 0, - "board_config_file": "", - "board_name": "", - "board_num": 0, - "board_type": 64, - "camera_file": "", - "exposure": 25000, - "folder": "model4\\", - "format": "None", - "frame_rate": 7.400000095367432, - "gain": 0, - "height": 2048, - "id": 4, - "loop": 1, - "mac_address": "", - "offset_x": 0, - "offset_y": 0, - "param_policy": 2, - "rely_on_camera": "", - "rotation_angle": 0, - "save": 1, - "save_img_suffix": ".JPG", - "savefile_rgb_swapped": false, - "showname": "相机四", - "trigger_source": "Line0", - "type": 140, - "width": 3072, - "zoom": 1 - }, - "LP-OCM-R060GC 00J50359927": { - "algorithm": 1, - "algorithm_dll": 1, - "auto_open": false, - "auto_push": true, - "balanceRatio": 0, - "balanceRatioSelector": 0, - "board_config_file": "", - "board_name": "", - "board_num": 0, - "board_type": 64, - "camera_file": "", - "exposure": 25000, - "folder": "model2\\", - "format": "None", - "frame_rate": 7.400000095367432, - "gain": 0, - "height": 2048, - "id": 2, - "loop": 1, - "mac_address": "", - "offset_x": 0, - "offset_y": 0, - "param_policy": 2, - "rely_on_camera": "", - "rotation_angle": 0, - "save": 1, - "save_img_suffix": ".JPG", - "savefile_rgb_swapped": false, - "showname": "相机二", - "trigger_source": "Line0", - "type": 140, - "width": 3072, - "zoom": 1 - }, - "LP-OCM-R060GC 00J50359938": { - "algorithm": 1, - "algorithm_dll": 1, - "auto_open": false, - "auto_push": true, - "balanceRatio": 0, - "balanceRatioSelector": 0, - "board_config_file": "", - "board_name": "", - "board_num": 0, - "board_type": 64, - "camera_file": "", - "exposure": 25000, - "folder": "model3\\", - "format": "None", - "frame_rate": 7.400000095367432, - "gain": 0, - "height": 2048, - "id": 3, - "loop": 1, - "mac_address": "", - "offset_x": 0, - "offset_y": 0, - "param_policy": 2, - "rely_on_camera": "", - "rotation_angle": 0, - "save": 1, - "save_img_suffix": ".JPG", - "savefile_rgb_swapped": false, - "showname": "相机三", - "trigger_source": "Line0", - "type": 140, - "width": 3072, - "zoom": 1 - }, - "LP-OCM-R060GC 00J50359945": { - "algorithm": 1, - "algorithm_dll": 1, - "auto_open": false, - "auto_push": true, - "balanceRatio": 0, - "balanceRatioSelector": 0, - "board_config_file": "", - "board_name": "", - "board_num": 0, - "board_type": 64, - "camera_file": "", - "exposure": 50000, - "folder": "model6\\", - "format": "None", - "frame_rate": 7.400000095367432, - "gain": 0, - "height": 2048, - "id": 6, - "loop": 1, - "mac_address": "", - "offset_x": 0, - "offset_y": 0, - "param_policy": 2, - "rely_on_camera": "", - "rotation_angle": 270, - "save": 0, - "save_img_suffix": ".JPG", - "savefile_rgb_swapped": false, - "showname": "相机六", - "trigger_source": "Line0", - "type": 140, - "width": 3072, - "zoom": 1 - } - }, + "devices": { + "LP-OCM-R060GC 00787720450": { + "algorithm": 1, + "algorithm_dll": 1, + "auto_open": false, + "auto_push": true, + "balanceRatio": 0, + "balanceRatioSelector": 0, + "board_config_file": "", + "board_name": "", + "board_num": 0, + "board_type": 64, + "camera_file": "", + "exposure": 10000, + "folder": "model1\\", + "format": "None", + "frame_rate": 9.3, + "gain": 2, + "height": 1200, + "id": 1, + "loop": 1, + "mac_address": "", + "offset_x": 0, + "offset_y": 0, + "param_policy": 2, + "rely_on_camera": "", + "rotation_angle": 0, + "save": 1, + "save_img_suffix": ".BMP", + "savefile_rgb_swapped": false, + "showname": "相机一", + "trigger_source": "Line0", + "type": 140, + "width": 1920, + "zoom": 1 + } + }, "top": { - "startID": 5, - "endID": 6 + "startID": 0, + "endID": 0 }, "side": { "startID": 1, - "endID": 4 + "endID": 1 } } diff --git a/runner17/Release/fileData/2121/1_310102_rlt.BMP b/runner17/Release/fileData/2121/1_310102_rlt.BMP new file mode 100644 index 0000000..23894f5 Binary files /dev/null and b/runner17/Release/fileData/2121/1_310102_rlt.BMP differ diff --git a/runner17/Release/fileData/intoStock/1.BMP b/runner17/Release/fileData/intoStock/1.BMP new file mode 100644 index 0000000..a396aa0 Binary files /dev/null and b/runner17/Release/fileData/intoStock/1.BMP differ diff --git a/runner17/Release/log/log-2024-01-03.log b/runner17/Release/log/log-2024-01-03.log deleted file mode 100644 index dea8857..0000000 --- a/runner17/Release/log/log-2024-01-03.log +++ /dev/null @@ -1,30 +0,0 @@ -Debug | 2024-01-03 17:13:11 | Decode smokeInfo from "D:/Code/Logistics/smokeboxidentification/runner17/Release\\user\\smokeInfo.xlsx" successed -Debug | 2024-01-03 17:13:11 | "D:/Code/Logistics/smokeboxidentification/runner17/Release\\templateNum" has not folder -Warning | 2024-01-03 17:13:11 | SerialNumber: "00J50359922" init failed -Warning | 2024-01-03 17:13:11 | QObject::moveToThread: Cannot move objects with a parent -Warning | 2024-01-03 17:13:12 | SerialNumber: "00J50359927" init failed -Warning | 2024-01-03 17:13:12 | SerialNumber: "00J50359938" init failed -Warning | 2024-01-03 17:13:12 | SerialNumber: "00J50359923" init failed -Warning | 2024-01-03 17:13:12 | SerialNumber: "00J50359918" init failed -Warning | 2024-01-03 17:13:13 | SerialNumber: "00J50359945" init failed -Debug | 2024-01-03 17:13:13 | m_vecPCamera size: 0 -Debug | 2024-01-03 17:13:13 | init CategoryMatcher successed -Debug | 2024-01-03 17:13:14 | delete netControl -Debug | 2024-01-03 17:13:14 | delete netControl finished -Debug | 2024-01-03 17:16:05 | Decode smokeInfo from "D:/Code/Logistics/smokeboxidentification/runner17/Release\\user\\smokeInfo.xlsx" successed -Debug | 2024-01-03 17:16:05 | "D:/Code/Logistics/smokeboxidentification/runner17/Release\\templateNum" has not folder -Warning | 2024-01-03 17:16:05 | SerialNumber: "00J50359922" init failed -Warning | 2024-01-03 17:16:06 | QObject::moveToThread: Cannot move objects with a parent -Debug | 2024-01-03 17:16:06 | Sensor -Debug | 2024-01-03 17:16:06 | CodeScan -Debug | 2024-01-03 17:16:06 | connect yidadui -Warning | 2024-01-03 17:16:06 | SerialNumber: "00J50359927" init failed -Warning | 2024-01-03 17:16:06 | SerialNumber: "00J50359938" init failed -Warning | 2024-01-03 17:16:06 | SerialNumber: "00J50359923" init failed -Warning | 2024-01-03 17:16:06 | SerialNumber: "00J50359918" init failed -Warning | 2024-01-03 17:16:07 | SerialNumber: "00J50359945" init failed -Debug | 2024-01-03 17:16:07 | m_vecPCamera size: 0 -Debug | 2024-01-03 17:16:07 | init CategoryMatcher successed -Debug | 2024-01-03 17:16:07 | over -Debug | 2024-01-03 17:16:09 | delete netControl -Debug | 2024-01-03 17:16:09 | delete netControl finished diff --git a/runner17/Release/log/log-2024-01-09.log b/runner17/Release/log/log-2024-01-09.log new file mode 100644 index 0000000..9f67ff4 --- /dev/null +++ b/runner17/Release/log/log-2024-01-09.log @@ -0,0 +1,73 @@ +Info | 2024-01-09 18:16:14 ܶ | initCamera +Debug | 2024-01-09 18:16:14 ܶ | Decode smokeInfo from "D:/Code/Logistics/smokeboxidentification/runner17/Release\\user\\smokeInfo.xlsx" successed +Debug | 2024-01-09 18:16:14 ܶ | "D:/Code/Logistics/smokeboxidentification/runner17/Release\\templateNum" has not folder +Debug | 2024-01-09 18:16:15 ܶ | Find device: "00787720450" +Debug | 2024-01-09 18:16:15 ܶ | m_vecPCamera size: 1 +Warning | 2024-01-09 18:16:15 ܶ | QObject::moveToThread: Cannot move objects with a parent +Debug | 2024-01-09 18:16:16 ܶ | init CategoryMatcher successed +Debug | 2024-01-09 18:16:16 ܶ | NetControl::onConnected +TPTcpClient::slotConnected +Debug | 2024-01-09 18:16:16 ܶ | ӳɹ +Debug | 2024-01-09 18:16:16 ܶ | Open camera: "00787720450" successed +Debug | 2024-01-09 18:16:16 ܶ | Start camera: "00787720450" successed +Debug | 2024-01-09 18:16:16 ܶ | Set device successed +Debug | 2024-01-09 18:16:16 ܶ | Set camera: "00787720450" software trigger successed +Warning | 2024-01-09 18:16:18 ܶ | i receive data from server: "GP&6&111&2121&1&310102&25>" +Debug | 2024-01-09 18:16:18 ܶ | msg: "GP&6&111&2121&1&310102&25>" content: "GP&6&111&2121&1&310102&25" +Debug | 2024-01-09 18:16:18 ܶ | strlist length: 7 head: "GP" +Info | 2024-01-09 18:16:18 ܶ | [captureSide]: Enter +Info | 2024-01-09 18:16:18 ܶ | [onCapture]: Enter +Info | 2024-01-09 18:16:18 ܶ | [onCapture]: cameraLocation = 0 +Info | 2024-01-09 18:16:18 ܶ | [onCapture]: Out +Debug | 2024-01-09 18:16:18 ܶ | start capture, length: 1 +Debug | 2024-01-09 18:16:18 ܶ | convert Mat successed! +Debug | 2024-01-09 18:16:18 ܶ | ת +Debug | 2024-01-09 18:16:18 ܶ | [Camera]: Side Camera Captured. +Debug | 2024-01-09 18:16:18 ܶ | Save image: ".\\fileData\\intoStock\\1.BMP" +Debug | 2024-01-09 18:16:18 ܶ | "Camera 00787720450 Match Start ..." +Info | 2024-01-09 18:16:18 ܶ | "Camera 00787720450 SetImageData OK!" +Critical | 2024-01-09 18:16:18 ܶ | strList.last() = "11" +Critical | 2024-01-09 18:16:18 ܶ | jieduan = "1" +Critical | 2024-01-09 18:16:18 ܶ | level = 1 +Debug | 2024-01-09 18:16:18 ܶ | Get TemplateImg OK! +Debug | 2024-01-09 18:16:18 ܶ | templateLevel = 1 +Info | 2024-01-09 18:16:18 ܶ | level = 1 +Info | 2024-01-09 18:16:18 ܶ | templateImgPath = "./templateImg/310102/310102-11.bmp" +Debug | 2024-01-09 18:16:18 ܶ | Level == 1 +Info | 2024-01-09 18:16:19 ܶ | valueMaxScore = 97.147 +Info | 2024-01-09 18:16:19 ܶ | indexMaxScore = true +Info | 2024-01-09 18:16:19 ܶ | 5 +Debug | 2024-01-09 18:16:19 ܶ | "Camera 00787720450 Match successful!" +Info | 2024-01-09 18:16:19 ܶ | fileName "1_310102_rlt.BMP" +Info | 2024-01-09 18:16:19 ܶ | filePath ".\\fileData\\2121\\1_310102_rlt.BMP" +Warning | 2024-01-09 18:16:22 ܶ | i receive data from server: "GP&6&111&2121&1&310102&25>" +Debug | 2024-01-09 18:16:22 ܶ | msg: "GP&6&111&2121&1&310102&25>" content: "GP&6&111&2121&1&310102&25" +Debug | 2024-01-09 18:16:22 ܶ | strlist length: 7 head: "GP" +Info | 2024-01-09 18:16:22 ܶ | [captureSide]: Enter +Info | 2024-01-09 18:16:22 ܶ | [onCapture]: Enter +Info | 2024-01-09 18:16:22 ܶ | [onCapture]: cameraLocation = 0 +Info | 2024-01-09 18:16:22 ܶ | [onCapture]: Out +Debug | 2024-01-09 18:16:22 ܶ | start capture, length: 1 +Debug | 2024-01-09 18:16:22 ܶ | convert Mat successed! +Debug | 2024-01-09 18:16:22 ܶ | ת +Debug | 2024-01-09 18:16:22 ܶ | [Camera]: Side Camera Captured. +Debug | 2024-01-09 18:16:22 ܶ | Save image: ".\\fileData\\intoStock\\1.BMP" +Debug | 2024-01-09 18:16:22 ܶ | "Camera 00787720450 Match Start ..." +Info | 2024-01-09 18:16:22 ܶ | "Camera 00787720450 SetImageData OK!" +Critical | 2024-01-09 18:16:22 ܶ | strList.last() = "11" +Critical | 2024-01-09 18:16:22 ܶ | jieduan = "1" +Critical | 2024-01-09 18:16:22 ܶ | level = 1 +Debug | 2024-01-09 18:16:22 ܶ | Get TemplateImg OK! +Debug | 2024-01-09 18:16:22 ܶ | templateLevel = 1 +Info | 2024-01-09 18:16:22 ܶ | level = 1 +Info | 2024-01-09 18:16:22 ܶ | templateImgPath = "./templateImg/310102/310102-11.bmp" +Debug | 2024-01-09 18:16:22 ܶ | Level == 1 +Info | 2024-01-09 18:16:22 ܶ | valueMaxScore = 97.147 +Info | 2024-01-09 18:16:22 ܶ | indexMaxScore = true +Info | 2024-01-09 18:16:22 ܶ | 5 +Debug | 2024-01-09 18:16:22 ܶ | "Camera 00787720450 Match successful!" +Info | 2024-01-09 18:16:22 ܶ | fileName "1_310102_rlt.BMP" +Info | 2024-01-09 18:16:22 ܶ | filePath ".\\fileData\\2121\\1_310102_rlt.BMP" +Debug | 2024-01-09 18:16:29 ܶ | delete netControl +Debug | 2024-01-09 18:16:29 ܶ | NetControl::onDisconnected +TPTcpClient::slotDisconnected diff --git a/runner17/Release/smokeBox.exe b/runner17/Release/smokeBox.exe index 42c62e9..42dcb1d 100644 Binary files a/runner17/Release/smokeBox.exe and b/runner17/Release/smokeBox.exe differ diff --git a/runner17/Release/templateImg/310102/310102-11.bmp b/runner17/Release/templateImg/310102/310102-11.bmp new file mode 100644 index 0000000..aaee9da Binary files /dev/null and b/runner17/Release/templateImg/310102/310102-11.bmp differ diff --git a/src/CameraControl.cpp b/src/CameraControl.cpp index 6654856..137c388 100644 --- a/src/CameraControl.cpp +++ b/src/CameraControl.cpp @@ -44,6 +44,7 @@ bool CameraControl::readCameraConfig(QString filePath) m_mapIdCameraInfoTop.clear(); m_mapSerialNumberIdSide.clear(); m_mapSerialNumberIdTop.clear(); + QFile file(filePath); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { @@ -57,12 +58,11 @@ bool CameraControl::readCameraConfig(QString filePath) qWarning() << "Ϊ"; return false; } - QJsonParseError err; QJsonDocument doc = QJsonDocument::fromJson(arr, &err); if (doc.isEmpty()) { - qWarning() << err.errorString(); //ӡʧϢ + qWarning() <<"[QJsonDocument]: "<< err.errorString(); //ӡʧϢ return false; } @@ -86,6 +86,7 @@ bool CameraControl::readCameraConfig(QString filePath) } return cameraType; }; + QJsonObject topObj = jsonObj.value("top").toObject(); int topStartId, topEndId; if (!topObj.isEmpty()) @@ -98,6 +99,7 @@ bool CameraControl::readCameraConfig(QString filePath) qWarning() << "top id error"; return false; } + QJsonObject sideObj = jsonObj.value("side").toObject(); int sideStartId, sideEndId; if (!sideObj.isEmpty()) @@ -110,6 +112,7 @@ bool CameraControl::readCameraConfig(QString filePath) qWarning() << "side id error"; return false; } + QJsonObject devicesObj = jsonObj.value("devices").toObject(); if (!devicesObj.isEmpty()) { QStringList devicesLabelList = devicesObj.keys(); @@ -148,6 +151,7 @@ bool CameraControl::readCameraConfig(QString filePath) m_mapIdCameraInfoSide[id] = cameraInfo; m_mapSerialNumberIdSide[cameraInfo.serialNumber] = id; } + } } } @@ -156,6 +160,7 @@ bool CameraControl::readCameraConfig(QString filePath) bool CameraControl::initCamera() { + qInfo() << "initCamera"; QList cameraInfoList = m_mapIdCameraInfoSide.values(); cameraInfoList.append(m_mapIdCameraInfoTop.values()); if (!loadCamera(cameraInfoList)) @@ -431,6 +436,8 @@ bool CameraControl::getSaveImgNameInfo(QString serialNumber, FileInfo& fileInfo) Q_SLOT void CameraControl::onCapture(int cameraLocation) { + qInfo() << "[onCapture]: Enter"; + qInfo() << "[onCapture]: cameraLocation = "<< cameraLocation; QStringList serialNumList; switch (cameraLocation) { @@ -445,6 +452,7 @@ Q_SLOT void CameraControl::onCapture(int cameraLocation) default: break; } + qInfo() << "[onCapture]: Out"; capture(serialNumList); } diff --git a/src/CameraControl.h b/src/CameraControl.h index 9d32fbc..4103472 100644 --- a/src/CameraControl.h +++ b/src/CameraControl.h @@ -18,7 +18,7 @@ struct CameraInfo int rotationAngle{ 0 }; //DǶ QString saveImgSuffix = ".bmp" ; //ͼʽ - + }; struct FileInfo diff --git a/src/CategoryMatcher.cpp b/src/CategoryMatcher.cpp index c21022a..499f8ff 100644 --- a/src/CategoryMatcher.cpp +++ b/src/CategoryMatcher.cpp @@ -127,6 +127,7 @@ bool CategoryMatcher::smokeMatch(const QString& typeNo, const ILImagePtr ilImgPt // ͬģ弶 for each (int level in keys) { + qInfo() << "level = " << level; QVector vecMatchSrore; QVector vecMatchRlts; QMap strScoreMap = templateObj.value(level); @@ -135,6 +136,7 @@ bool CategoryMatcher::smokeMatch(const QString& typeNo, const ILImagePtr ilImgPt //Ҫ֤û1ģ壬2ģͼ QString templateImgPath = it.key(); + qInfo() << "templateImgPath = "<< templateImgPath; ILImagePtr ilTemplatePtr(__uuidof(LImage)); ilTemplatePtr->Load(templateImgPath.toStdString().c_str()); if (ilTemplatePtr->Void()) @@ -156,17 +158,18 @@ bool CategoryMatcher::smokeMatch(const QString& typeNo, const ILImagePtr ilImgPt if (level == 1) // ģ { + qDebug() << "Level == 1"; ILImageArithmPtr imgArithm(__uuidof(LImageArithm)); imgArithm->Resize(ilImgPtr, 0.5, 0.5, LPVInterNearest, img); } + LPVErrorCode err = m_ilmatch->Match((level == 1 ? img : ilImgPtr), nullptr, &matchResults); LPVErrorCode errF = m_ilmatchF->Match((level == 1 ? img : ilImgPtr), nullptr, &matchResultsF); if (err < LPVErrorCode::LPVNoError || errF < LPVErrorCode::LPVNoError) { - //continue; // match failed + continue; // match failed } int objCount = matchResults->Count() + matchResultsF->Count(); - if (objCount > 0) { double valueMaxScore = -1; @@ -188,7 +191,7 @@ bool CategoryMatcher::smokeMatch(const QString& typeNo, const ILImagePtr ilImgPt auto maxPos = std::max_element(matchSrore.begin(), matchSrore.end()); valueMaxScore = *maxPos; indexMaxScore = maxPos - matchSrore.begin(); - + vecMatchSrore.push_back(valueMaxScore); if (indexMaxScore < matchResults->Count()) { @@ -255,10 +258,13 @@ bool CategoryMatcher::getTemplateImgFileInfo(const QString& folderPath, Template || fileName.endsWith(".jpeg") || fileName.endsWith(".JPEG") || fileName.endsWith(".jpg") || fileName.endsWith(".JPG")) { - QStringList strList = imgFileInfo.baseName().split("_"); + QStringList strList = imgFileInfo.baseName().split("-"); QString templateImgPath = imgFileInfo.filePath(); //··ʱȡʧ int level = strList.last().mid(0, 1).toInt(); + qCritical() << "strList.last() = " << strList.last(); + qCritical() << "jieduan = " << strList.last().mid(0, 1); + qCritical() << "level = " << level; templateObject[level].insert(templateImgPath, 70); @@ -312,7 +318,7 @@ void CategoryMatcher::drawImage(ILImagePtr image, std::pairSetImage(image); - m_display->AddObject(rltStr,0); + //m_display->AddObject(rltStr,0); rltStr.clear(); for each(ILMatchResultPtr matchRltPtr in vecMatchRlts) @@ -326,7 +332,7 @@ void CategoryMatcher::drawImage(ILImagePtr image, std::pairAddObject(rltStr, 0); + //m_display->AddObject(rltStr, 0); } } diff --git a/src/CategoryMatcher.h b/src/CategoryMatcher.h index 4a3e37b..d232143 100644 --- a/src/CategoryMatcher.h +++ b/src/CategoryMatcher.h @@ -15,14 +15,6 @@ #include #include -#include "LPVCore.h" -#include "LPVGeom.h" -#include "LPVPat.h" -#include "LPVImgProc.h" -#include "DisplayHelper.h" -#include "LPVCalib.h" -#include "LPVDisplay.h" - #include "commonDefine.h" diff --git a/src/QModuleChoice.cpp b/src/QModuleChoice.cpp deleted file mode 100644 index 44e7247..0000000 --- a/src/QModuleChoice.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "QModuleChoice.h" - -QModuleChoice::QModuleChoice(QWidget *parent) - : QWidget(parent) - , ui(new Ui::QModuleChoiceClass()) -{ - ui->setupUi(this); -} - -QModuleChoice::~QModuleChoice() -{ - delete ui; -} diff --git a/src/QModuleChoice.h b/src/QModuleChoice.h deleted file mode 100644 index 866b501..0000000 --- a/src/QModuleChoice.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include -#include "ui_QModuleChoice.h" - -QT_BEGIN_NAMESPACE -namespace Ui { class QModuleChoiceClass; }; -QT_END_NAMESPACE - -class QModuleChoice : public QWidget -{ - Q_OBJECT - -public: - QModuleChoice(QWidget *parent = nullptr); - ~QModuleChoice(); - -private: - Ui::QModuleChoiceClass *ui; -}; diff --git a/src/SmokeBoxIdentification.cpp b/src/SmokeBoxIdentification.cpp index 15a45ab..24dbace 100644 --- a/src/SmokeBoxIdentification.cpp +++ b/src/SmokeBoxIdentification.cpp @@ -129,11 +129,13 @@ Q_SLOT void SmokeBoxIdentification::onActionClicked() void SmokeBoxIdentification::captureTop() { + qInfo() << "[captureTop]: Enter"; emit sgCapture(eCameraLocation::emTop); } void SmokeBoxIdentification::captureSide() { + qInfo() << "[captureSide]: Enter"; emit sgCapture(eCameraLocation::emSide); } @@ -162,8 +164,9 @@ void SmokeBoxIdentification::saveImage(const QVector& vecImageInfo, i .arg(m_currtIntoStockInfo.stockNum).arg(m_currtIntoStockInfo.taskNum); break; default: - qDebug() << "Mode: " << workMode << "do not save Image"; - return; + dataSaveFolderPath = QString("%1\\%2").arg(FILE_STORAGE_PATH).arg(m_currtIntoStockInfo.taskNum); + //qDebug() << "Mode: " << workMode << "do not save Image"; + //return; } QDir folder(dataSaveFolderPath); if (!folder.exists()) @@ -189,6 +192,7 @@ void SmokeBoxIdentification::saveImage(const QVector& vecImageInfo, i .arg(m_currtIntoStockInfo.stockNum).arg(m_currtIntoStockInfo.taskNum).arg(fileInfo.name); m_currtIntoStockInfo.imagesPathList.push_back(filePathSend); } + saveImage(vecImageInfo.at(i).image, filePath); } } @@ -214,17 +218,22 @@ Q_SLOT void SmokeBoxIdentification::onCapturedImage(const QVector& ve } else if (cameraLocation == eCameraLocation::emSide) { - qDebug() << "side captured"; +#if IMAGEDRAWING==LPV + qDebug() << "[Camera]: Side Camera Captured."; QtConcurrent::run([=] { saveImage(vecImageInfo, m_workMode); + bool bRlt = false; QString typeNum = m_currtStockCheckInfo.smokeTypeNum; cv::Mat imgRltMat; - QString dataSaveFolder = QString("%1\\%2\\%3").arg(FILE_STORAGE_PATH) - .arg(m_currtStockCheckInfo.stockNum).arg(m_currtStockCheckInfo.taskNum); -#if IMAGEDRAWING == LPV + // ݶͨѶ֮ǰstockNumݸĴ洢ַ + //QString dataSaveFolder = QString("%1\\%2\\%3").arg(FILE_STORAGE_PATH) + // .arg(m_currtStockCheckInfo.stockNum).arg(m_currtStockCheckInfo.taskNum); + QString dataSaveFolder = QString("%1\\%2").arg(FILE_STORAGE_PATH) + .arg(m_currtStockCheckInfo.taskNum); + for each (const ImageInfo& imgInfo in vecImageInfo) { QString str = QString("Camera %1 Match Start ...").arg(imgInfo.cameraSn); @@ -234,6 +243,9 @@ Q_SLOT void SmokeBoxIdentification::onCapturedImage(const QVector& ve { ILImagePtr image(__uuidof(LImage)); image->SetImageData(imgInfo.image.cols, imgInfo.image.rows, (void*)imgInfo.image.data, imgInfo.image.step, 0); + QString str = QString("Camera %1 SetImageData OK!").arg(imgInfo.cameraSn); + qInfo() << str; + image->Load("D:/Code/Logistics/smokeboxidentification/tpvs17/SmokeBoxIdentification/log/TestSave.bmp"); if (m_pCategoryMatcher->smokeMatch(typeNum, image)) { @@ -243,20 +255,30 @@ Q_SLOT void SmokeBoxIdentification::onCapturedImage(const QVector& ve FileInfo fileInfo = imgInfo.saveImgInfo; QString fileName = QString("%1_%2_rlt%3").arg(fileInfo.strId) .arg(m_currtStockCheckInfo.smokeTypeNum).arg(fileInfo.suffix); + qInfo() << "fileName" << fileName; QString filePath = QString("%1\\%2").arg(dataSaveFolder).arg(fileName); + qInfo() << "filePath" << filePath; m_pCategoryMatcher->saveResultsImage(filePath); break; } - } else { qDebug() << "imgInfo.image is Empty!"; } } + }); +#elif IMAGEDRAWING==OPENCV + qDebug() << "side captured"; + QtConcurrent::run([=] { + saveImage(vecImageInfo, m_workMode); + bool bRlt = false; + QString typeNum = m_currtStockCheckInfo.smokeTypeNum; + cv::Mat imgRltMat; + QString dataSaveFolder = QString("%1\\%2\\%3").arg(FILE_STORAGE_PATH) + .arg(m_currtStockCheckInfo.stockNum).arg(m_currtStockCheckInfo.taskNum); -#elif IMAGEDRAWING == OPENCV for each (const ImageInfo& imgInfo in vecImageInfo) { QString str = QString("Camera %1 Match Start ...").arg(imgInfo.cameraSn); @@ -295,8 +317,9 @@ Q_SLOT void SmokeBoxIdentification::onCapturedImage(const QVector& ve // QImage resultQImg((const unsigned char*)imgRltMat.data, imgRltMat.cols, imgRltMat.rows, imgRltMat.step, QImage::Format_RGB888); // emit sgShowImage(m_pShowRltImgLabel, resultQImg); //} -#endif + }); +#endif } } @@ -352,11 +375,11 @@ Q_SLOT void SmokeBoxIdentification::onDecodeMsg(const QString& msg) qDebug() << "ȡλ"; QString taskNum = strList.at(2); QString currentTaskNum = m_currtStockCheckInfo.taskNum; - if (m_workMode == WorkMode::StockCheck) - { + //if (m_workMode == WorkMode::StockCheck) + //{ captureSide(); - captureTop(); - } + //captureTop(); + //} } } else if (strList.at(0) == INTO_STOCK_HEAD) @@ -388,6 +411,18 @@ Q_SLOT void SmokeBoxIdentification::onDecodeMsg(const QString& msg) } } } + else if (strList.at(0) == START_CAPTURE) + { + StockCheckInfo stockCheckInfo; + stockCheckInfo.streetName = strList.at(1); + stockCheckInfo.id = strList.at(2); + stockCheckInfo.taskNum = strList.at(3); + stockCheckInfo.stockLocation = strList.at(4); + stockCheckInfo.smokeTypeNum = strList.at(5); + stockCheckInfo.smokeQuantity = strList.at(6); + m_currtStockCheckInfo = stockCheckInfo; + captureSide(); + } } Q_SLOT void SmokeBoxIdentification::onNumStatistic(QString typeNum) diff --git a/src/SmokeBoxIdentification.h b/src/SmokeBoxIdentification.h index c003ef4..5ac64f5 100644 --- a/src/SmokeBoxIdentification.h +++ b/src/SmokeBoxIdentification.h @@ -5,8 +5,6 @@ #include #include -//#include".\xlsxdocument.h" -//#include".\xlsxworkbook.h" #include".\Qt5Xlsx\xlsxdocument.h" #include".\Qt5Xlsx\xlsxworkbook.h" @@ -23,6 +21,7 @@ #include "QNumTemplateBuild.h" #include "ui_SmokeBoxIdentification.h" + //#define IMAGEDRAWING OPENCV #define IMAGEDRAWING LPV @@ -68,9 +67,18 @@ struct EmptyCheckInfo struct StockCheckInfo { // "SC&6&UL062015020111&6335&37010106&30&N>" + // ¹GP&111&6&2121&1&S001&25> + // 111:ID + // 6: + // 2121:- + // 112 + // S001:Ʒ-λ͵Ʒ + // QString streetName; // 6 QString taskNum; // 6335 QString stockNum; // λUL062015020111 6ŶѶ2ұߣ + QString id = 0; + QString stockLocation = 0; // 12ң0Ϊ֮ǰ QString smokeTypeNum; //λ͵Ʒ37010106 QString smokeQuantity; //λ͵30 QString smokeTypeNumRlt; //̵ʶƷ @@ -99,6 +107,10 @@ struct StockCheckInfo // this->correctness = obj.correctness; // return *this; //} + + + + }; @@ -169,9 +181,10 @@ private: void moduleLoading(); - ModuleParam m_moduleParam; + + QMap m_mapSmokeCode2Name; QMap m_mapSmokeName2TemplateFolderName; diff --git a/src/common/commonDefine.h b/src/common/commonDefine.h index 44bb540..77924f9 100644 --- a/src/common/commonDefine.h +++ b/src/common/commonDefine.h @@ -13,6 +13,14 @@ #include "QZkJsonParser.h" #include "lp_singleton.h" +#include "LPVCore.h" +#include "LPVGeom.h" +#include "LPVPat.h" +#include "LPVImgProc.h" +#include "DisplayHelper.h" +#include "LPVDisplay.h" +#include "LPVCalib.h" + #define DELETE_POINTER(p) if (p) {delete p; p = NULL;} #define MODULE_CONFIG "\\config\\module.json" @@ -20,6 +28,9 @@ #define NET_CONFIG "\\config\\netSetting.json" #define COM_CONFIG "\\config\\comSetting.json" #define MATCHER_CONFIG "\\config\\match.json" +#define CALIBRATION_LEFT "\\config\\left.calib" +#define CALIBRATION_RIGHT "\\config\\right.calib" + #define SMOKEINFO_XLSX_CONFIG "\\user\\smokeInfo.xlsx" #define FILE_STORAGE_PATH ".\\fileData" @@ -39,6 +50,7 @@ #define CODE_CONTENT_SPLIT "," #define CONTENT_SPLIT ";" #define END_SYMBOL ">" +#define START_CAPTURE "GP" #define LP_COLOR_CONTROL 0x88 #define LP_D1TOD80 0x86 @@ -119,8 +131,8 @@ struct debugMsg enum eCameraLocation { - emSide=0, - emTop + emSide=0, // Чɼ + emTop // õ }; enum eSideID { diff --git a/tpvs17/SmokeBoxIdentification/QModuleChoice.ui b/tpvs17/SmokeBoxIdentification/QModuleChoice.ui deleted file mode 100644 index 40231d5..0000000 --- a/tpvs17/SmokeBoxIdentification/QModuleChoice.ui +++ /dev/null @@ -1,50 +0,0 @@ - - - QModuleChoiceClass - - - - 0 - 0 - 190 - 111 - - - - QModuleChoice - - - - - - 扫码器 - - - - - - - 传感器 - - - - - - - 请选择应用的模块: - - - - - - - 确定 - - - - - - - - - diff --git a/tpvs17/SmokeBoxIdentification/fileData/intoStock/1.BMP b/tpvs17/SmokeBoxIdentification/fileData/intoStock/1.BMP new file mode 100644 index 0000000..65e4449 Binary files /dev/null and b/tpvs17/SmokeBoxIdentification/fileData/intoStock/1.BMP differ