修改相机json,图像接入算法和通讯

master
zhou.mengjia 2 years ago
parent 952bce1b85
commit 00cd7ff62c

@ -6,6 +6,16 @@ Identify the types and quantities of smoke boxes
1、2D模板匹配算法修改 1、2D模板匹配算法修改
2、相机采图后至算法使用期间通讯格式、图像保存等各种规范修改。
遗留冲突问题:
1、ADModule中有个确认WorkMode问题怀疑可能是出入库之前要做区别导致很多相机操作是跟WorkMode有关的。
SmokeBoxIdentification.cpp中根据STOCK_CHECK_HEAD等关键词选择哪个相机进行拍照。 SmokeBoxIdentification.cpp中根据STOCK_CHECK_HEAD等关键词选择哪个相机进行拍照。

@ -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
}
}

@ -1,222 +1,47 @@
{ {
"devices": { "devices": {
"LP-OCM-R060GC 00J50359918": { "LP-OCM-R060GC 00787720450": {
"algorithm": 1, "algorithm": 1,
"algorithm_dll": 1, "algorithm_dll": 1,
"auto_open": false, "auto_open": false,
"auto_push": true, "auto_push": true,
"balanceRatio": 1868, "balanceRatio": 0,
"balanceRatioSelector": 0, "balanceRatioSelector": 0,
"board_config_file": "", "board_config_file": "",
"board_name": "", "board_name": "",
"board_num": 0, "board_num": 0,
"board_type": 64, "board_type": 64,
"camera_file": "", "camera_file": "",
"exposure": 50000, "exposure": 10000,
"folder": "model5\\", "folder": "model1\\",
"format": "None", "format": "None",
"frame_rate": 7.400000095367432, "frame_rate": 9.3,
"gain": 1.0052000284194946, "gain": 2,
"height": 2048, "height": 1200,
"id": 5, "id": 1,
"loop": 1, "loop": 1,
"mac_address": "", "mac_address": "",
"offset_x": 0, "offset_x": 0,
"offset_y": 0, "offset_y": 0,
"param_policy": 2, "param_policy": 2,
"rely_on_camera": "", "rely_on_camera": "",
"rotation_angle": 90, "rotation_angle": 0,
"save": 0, "save": 1,
"save_img_suffix": ".JPG", "save_img_suffix": ".BMP",
"savefile_rgb_swapped": false, "savefile_rgb_swapped": false,
"showname": "相机五", "showname": "相机一",
"trigger_source": "Line0", "trigger_source": "Line0",
"type": 140, "type": 140,
"width": 3072, "width": 1920,
"zoom": 1 "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": { "top": {
"startID": 5, "startID": 0,
"endID": 6 "endID": 0
}, },
"side": { "side": {
"startID": 1, "startID": 1,
"endID": 4 "endID": 1
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

@ -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

@ -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

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

@ -44,6 +44,7 @@ bool CameraControl::readCameraConfig(QString filePath)
m_mapIdCameraInfoTop.clear(); m_mapIdCameraInfoTop.clear();
m_mapSerialNumberIdSide.clear(); m_mapSerialNumberIdSide.clear();
m_mapSerialNumberIdTop.clear(); m_mapSerialNumberIdTop.clear();
QFile file(filePath); QFile file(filePath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
@ -57,12 +58,11 @@ bool CameraControl::readCameraConfig(QString filePath)
qWarning() << "ÄÚÈÝΪ¿Õ"; qWarning() << "ÄÚÈÝΪ¿Õ";
return false; return false;
} }
QJsonParseError err; QJsonParseError err;
QJsonDocument doc = QJsonDocument::fromJson(arr, &err); QJsonDocument doc = QJsonDocument::fromJson(arr, &err);
if (doc.isEmpty()) if (doc.isEmpty())
{ {
qWarning() << err.errorString(); //打印失败信息 qWarning() <<"[QJsonDocument]: "<< err.errorString(); //打印失败信息
return false; return false;
} }
@ -86,6 +86,7 @@ bool CameraControl::readCameraConfig(QString filePath)
} }
return cameraType; return cameraType;
}; };
QJsonObject topObj = jsonObj.value("top").toObject(); QJsonObject topObj = jsonObj.value("top").toObject();
int topStartId, topEndId; int topStartId, topEndId;
if (!topObj.isEmpty()) if (!topObj.isEmpty())
@ -98,6 +99,7 @@ bool CameraControl::readCameraConfig(QString filePath)
qWarning() << "top id error"; qWarning() << "top id error";
return false; return false;
} }
QJsonObject sideObj = jsonObj.value("side").toObject(); QJsonObject sideObj = jsonObj.value("side").toObject();
int sideStartId, sideEndId; int sideStartId, sideEndId;
if (!sideObj.isEmpty()) if (!sideObj.isEmpty())
@ -110,6 +112,7 @@ bool CameraControl::readCameraConfig(QString filePath)
qWarning() << "side id error"; qWarning() << "side id error";
return false; return false;
} }
QJsonObject devicesObj = jsonObj.value("devices").toObject(); QJsonObject devicesObj = jsonObj.value("devices").toObject();
if (!devicesObj.isEmpty()) { if (!devicesObj.isEmpty()) {
QStringList devicesLabelList = devicesObj.keys(); QStringList devicesLabelList = devicesObj.keys();
@ -148,6 +151,7 @@ bool CameraControl::readCameraConfig(QString filePath)
m_mapIdCameraInfoSide[id] = cameraInfo; m_mapIdCameraInfoSide[id] = cameraInfo;
m_mapSerialNumberIdSide[cameraInfo.serialNumber] = id; m_mapSerialNumberIdSide[cameraInfo.serialNumber] = id;
} }
} }
} }
} }
@ -156,6 +160,7 @@ bool CameraControl::readCameraConfig(QString filePath)
bool CameraControl::initCamera() bool CameraControl::initCamera()
{ {
qInfo() << "initCamera";
QList<CameraInfo> cameraInfoList = m_mapIdCameraInfoSide.values(); QList<CameraInfo> cameraInfoList = m_mapIdCameraInfoSide.values();
cameraInfoList.append(m_mapIdCameraInfoTop.values()); cameraInfoList.append(m_mapIdCameraInfoTop.values());
if (!loadCamera(cameraInfoList)) if (!loadCamera(cameraInfoList))
@ -431,6 +436,8 @@ bool CameraControl::getSaveImgNameInfo(QString serialNumber, FileInfo& fileInfo)
Q_SLOT void CameraControl::onCapture(int cameraLocation) Q_SLOT void CameraControl::onCapture(int cameraLocation)
{ {
qInfo() << "[onCapture]: Enter";
qInfo() << "[onCapture]: cameraLocation = "<< cameraLocation;
QStringList serialNumList; QStringList serialNumList;
switch (cameraLocation) switch (cameraLocation)
{ {
@ -445,6 +452,7 @@ Q_SLOT void CameraControl::onCapture(int cameraLocation)
default: default:
break; break;
} }
qInfo() << "[onCapture]: Out";
capture(serialNumList); capture(serialNumList);
} }

@ -18,7 +18,7 @@ struct CameraInfo
int rotationAngle{ 0 }; //旋轉角度 int rotationAngle{ 0 }; //旋轉角度
QString saveImgSuffix = ".bmp" ; //保存的图像格式 QString saveImgSuffix = ".bmp" ; //保存的图像格式
}; };
struct FileInfo struct FileInfo

@ -127,6 +127,7 @@ bool CategoryMatcher::smokeMatch(const QString& typeNo, const ILImagePtr ilImgPt
// 遍历不同模板级别 // 遍历不同模板级别
for each (int level in keys) for each (int level in keys)
{ {
qInfo() << "level = " << level;
QVector<double> vecMatchSrore; QVector<double> vecMatchSrore;
QVector<ILMatchResultPtr> vecMatchRlts; QVector<ILMatchResultPtr> vecMatchRlts;
QMap<QString, int> strScoreMap = templateObj.value(level); QMap<QString, int> strScoreMap = templateObj.value(level);
@ -135,6 +136,7 @@ bool CategoryMatcher::smokeMatch(const QString& typeNo, const ILImagePtr ilImgPt
//需要验证没用1类模板但有2类模板的图 //需要验证没用1类模板但有2类模板的图
QString templateImgPath = it.key(); QString templateImgPath = it.key();
qInfo() << "templateImgPath = "<< templateImgPath;
ILImagePtr ilTemplatePtr(__uuidof(LImage)); ILImagePtr ilTemplatePtr(__uuidof(LImage));
ilTemplatePtr->Load(templateImgPath.toStdString().c_str()); ilTemplatePtr->Load(templateImgPath.toStdString().c_str());
if (ilTemplatePtr->Void()) if (ilTemplatePtr->Void())
@ -156,17 +158,18 @@ bool CategoryMatcher::smokeMatch(const QString& typeNo, const ILImagePtr ilImgPt
if (level == 1) // 大模板 if (level == 1) // 大模板
{ {
qDebug() << "Level == 1";
ILImageArithmPtr imgArithm(__uuidof(LImageArithm)); ILImageArithmPtr imgArithm(__uuidof(LImageArithm));
imgArithm->Resize(ilImgPtr, 0.5, 0.5, LPVInterNearest, img); imgArithm->Resize(ilImgPtr, 0.5, 0.5, LPVInterNearest, img);
} }
LPVErrorCode err = m_ilmatch->Match((level == 1 ? img : ilImgPtr), nullptr, &matchResults); LPVErrorCode err = m_ilmatch->Match((level == 1 ? img : ilImgPtr), nullptr, &matchResults);
LPVErrorCode errF = m_ilmatchF->Match((level == 1 ? img : ilImgPtr), nullptr, &matchResultsF); LPVErrorCode errF = m_ilmatchF->Match((level == 1 ? img : ilImgPtr), nullptr, &matchResultsF);
if (err < LPVErrorCode::LPVNoError || errF < LPVErrorCode::LPVNoError) { if (err < LPVErrorCode::LPVNoError || errF < LPVErrorCode::LPVNoError) {
//continue; // match failed continue; // match failed
} }
int objCount = matchResults->Count() + matchResultsF->Count(); int objCount = matchResults->Count() + matchResultsF->Count();
if (objCount > 0) if (objCount > 0)
{ {
double valueMaxScore = -1; 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()); auto maxPos = std::max_element(matchSrore.begin(), matchSrore.end());
valueMaxScore = *maxPos; valueMaxScore = *maxPos;
indexMaxScore = maxPos - matchSrore.begin(); indexMaxScore = maxPos - matchSrore.begin();
vecMatchSrore.push_back(valueMaxScore); vecMatchSrore.push_back(valueMaxScore);
if (indexMaxScore < matchResults->Count()) if (indexMaxScore < matchResults->Count())
{ {
@ -255,10 +258,13 @@ bool CategoryMatcher::getTemplateImgFileInfo(const QString& folderPath, Template
|| fileName.endsWith(".jpeg") || fileName.endsWith(".JPEG") || fileName.endsWith(".jpeg") || fileName.endsWith(".JPEG")
|| fileName.endsWith(".jpg") || fileName.endsWith(".JPG")) || fileName.endsWith(".jpg") || fileName.endsWith(".JPG"))
{ {
QStringList strList = imgFileInfo.baseName().split("_"); QStringList strList = imgFileInfo.baseName().split("-");
QString templateImgPath = imgFileInfo.filePath(); //相对路径,避免路径存在中文时读取失败 QString templateImgPath = imgFileInfo.filePath(); //相对路径,避免路径存在中文时读取失败
int level = strList.last().mid(0, 1).toInt(); 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); templateObject[level].insert(templateImgPath, 70);
@ -312,7 +318,7 @@ void CategoryMatcher::drawImage(ILImagePtr image, std::pair<int, QVector<ILMatch
//在Display上绘制图像+结果 //在Display上绘制图像+结果
m_display->SetImage(image); m_display->SetImage(image);
m_display->AddObject(rltStr,0); //m_display->AddObject(rltStr,0);
rltStr.clear(); rltStr.clear();
for each(ILMatchResultPtr matchRltPtr in vecMatchRlts) for each(ILMatchResultPtr matchRltPtr in vecMatchRlts)
@ -326,7 +332,7 @@ void CategoryMatcher::drawImage(ILImagePtr image, std::pair<int, QVector<ILMatch
if (!rltStr.isEmpty()) if (!rltStr.isEmpty())
{ {
m_display->AddObject(rltStr, 0); //m_display->AddObject(rltStr, 0);
} }
} }

@ -15,14 +15,6 @@
#include <opencv2/imgproc/imgproc.hpp> #include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp> #include <opencv2/highgui/highgui.hpp>
#include "LPVCore.h"
#include "LPVGeom.h"
#include "LPVPat.h"
#include "LPVImgProc.h"
#include "DisplayHelper.h"
#include "LPVCalib.h"
#include "LPVDisplay.h"
#include "commonDefine.h" #include "commonDefine.h"

@ -1,13 +0,0 @@
#include "QModuleChoice.h"
QModuleChoice::QModuleChoice(QWidget *parent)
: QWidget(parent)
, ui(new Ui::QModuleChoiceClass())
{
ui->setupUi(this);
}
QModuleChoice::~QModuleChoice()
{
delete ui;
}

@ -1,20 +0,0 @@
#pragma once
#include <QWidget>
#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;
};

@ -129,11 +129,13 @@ Q_SLOT void SmokeBoxIdentification::onActionClicked()
void SmokeBoxIdentification::captureTop() void SmokeBoxIdentification::captureTop()
{ {
qInfo() << "[captureTop]: Enter";
emit sgCapture(eCameraLocation::emTop); emit sgCapture(eCameraLocation::emTop);
} }
void SmokeBoxIdentification::captureSide() void SmokeBoxIdentification::captureSide()
{ {
qInfo() << "[captureSide]: Enter";
emit sgCapture(eCameraLocation::emSide); emit sgCapture(eCameraLocation::emSide);
} }
@ -162,8 +164,9 @@ void SmokeBoxIdentification::saveImage(const QVector<ImageInfo>& vecImageInfo, i
.arg(m_currtIntoStockInfo.stockNum).arg(m_currtIntoStockInfo.taskNum); .arg(m_currtIntoStockInfo.stockNum).arg(m_currtIntoStockInfo.taskNum);
break; break;
default: default:
qDebug() << "Mode: " << workMode << "do not save Image"; dataSaveFolderPath = QString("%1\\%2").arg(FILE_STORAGE_PATH).arg(m_currtIntoStockInfo.taskNum);
return; //qDebug() << "Mode: " << workMode << "do not save Image";
//return;
} }
QDir folder(dataSaveFolderPath); QDir folder(dataSaveFolderPath);
if (!folder.exists()) if (!folder.exists())
@ -189,6 +192,7 @@ void SmokeBoxIdentification::saveImage(const QVector<ImageInfo>& vecImageInfo, i
.arg(m_currtIntoStockInfo.stockNum).arg(m_currtIntoStockInfo.taskNum).arg(fileInfo.name); .arg(m_currtIntoStockInfo.stockNum).arg(m_currtIntoStockInfo.taskNum).arg(fileInfo.name);
m_currtIntoStockInfo.imagesPathList.push_back(filePathSend); m_currtIntoStockInfo.imagesPathList.push_back(filePathSend);
} }
saveImage(vecImageInfo.at(i).image, filePath); saveImage(vecImageInfo.at(i).image, filePath);
} }
} }
@ -214,17 +218,22 @@ Q_SLOT void SmokeBoxIdentification::onCapturedImage(const QVector<ImageInfo>& ve
} }
else if (cameraLocation == eCameraLocation::emSide) else if (cameraLocation == eCameraLocation::emSide)
{ {
qDebug() << "side captured"; #if IMAGEDRAWING==LPV
qDebug() << "[Camera]: Side Camera Captured.";
QtConcurrent::run([=] { QtConcurrent::run([=] {
saveImage(vecImageInfo, m_workMode); saveImage(vecImageInfo, m_workMode);
bool bRlt = false; bool bRlt = false;
QString typeNum = m_currtStockCheckInfo.smokeTypeNum; QString typeNum = m_currtStockCheckInfo.smokeTypeNum;
cv::Mat imgRltMat; 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) for each (const ImageInfo& imgInfo in vecImageInfo)
{ {
QString str = QString("Camera %1 Match Start ...").arg(imgInfo.cameraSn); QString str = QString("Camera %1 Match Start ...").arg(imgInfo.cameraSn);
@ -234,6 +243,9 @@ Q_SLOT void SmokeBoxIdentification::onCapturedImage(const QVector<ImageInfo>& ve
{ {
ILImagePtr image(__uuidof(LImage)); ILImagePtr image(__uuidof(LImage));
image->SetImageData(imgInfo.image.cols, imgInfo.image.rows, (void*)imgInfo.image.data, imgInfo.image.step, 0); 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)) if (m_pCategoryMatcher->smokeMatch(typeNum, image))
{ {
@ -243,20 +255,30 @@ Q_SLOT void SmokeBoxIdentification::onCapturedImage(const QVector<ImageInfo>& ve
FileInfo fileInfo = imgInfo.saveImgInfo; FileInfo fileInfo = imgInfo.saveImgInfo;
QString fileName = QString("%1_%2_rlt%3").arg(fileInfo.strId) QString fileName = QString("%1_%2_rlt%3").arg(fileInfo.strId)
.arg(m_currtStockCheckInfo.smokeTypeNum).arg(fileInfo.suffix); .arg(m_currtStockCheckInfo.smokeTypeNum).arg(fileInfo.suffix);
qInfo() << "fileName" << fileName;
QString filePath = QString("%1\\%2").arg(dataSaveFolder).arg(fileName); QString filePath = QString("%1\\%2").arg(dataSaveFolder).arg(fileName);
qInfo() << "filePath" << filePath;
m_pCategoryMatcher->saveResultsImage(filePath); m_pCategoryMatcher->saveResultsImage(filePath);
break; break;
} }
} }
else else
{ {
qDebug() << "imgInfo.image is Empty!"; 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) for each (const ImageInfo& imgInfo in vecImageInfo)
{ {
QString str = QString("Camera %1 Match Start ...").arg(imgInfo.cameraSn); QString str = QString("Camera %1 Match Start ...").arg(imgInfo.cameraSn);
@ -295,8 +317,9 @@ Q_SLOT void SmokeBoxIdentification::onCapturedImage(const QVector<ImageInfo>& ve
// QImage resultQImg((const unsigned char*)imgRltMat.data, imgRltMat.cols, imgRltMat.rows, imgRltMat.step, QImage::Format_RGB888); // QImage resultQImg((const unsigned char*)imgRltMat.data, imgRltMat.cols, imgRltMat.rows, imgRltMat.step, QImage::Format_RGB888);
// emit sgShowImage(m_pShowRltImgLabel, resultQImg); // emit sgShowImage(m_pShowRltImgLabel, resultQImg);
//} //}
#endif
}); });
#endif
} }
} }
@ -352,11 +375,11 @@ Q_SLOT void SmokeBoxIdentification::onDecodeMsg(const QString& msg)
qDebug() << "È¡»õµ½Î»"; qDebug() << "È¡»õµ½Î»";
QString taskNum = strList.at(2); QString taskNum = strList.at(2);
QString currentTaskNum = m_currtStockCheckInfo.taskNum; QString currentTaskNum = m_currtStockCheckInfo.taskNum;
if (m_workMode == WorkMode::StockCheck) //if (m_workMode == WorkMode::StockCheck)
{ //{
captureSide(); captureSide();
captureTop(); //captureTop();
} //}
} }
} }
else if (strList.at(0) == INTO_STOCK_HEAD) 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) Q_SLOT void SmokeBoxIdentification::onNumStatistic(QString typeNum)

@ -5,8 +5,6 @@
#include <QtWidgets/QMainWindow> #include <QtWidgets/QMainWindow>
#include <QtConcurrent/QtConcurrent> #include <QtConcurrent/QtConcurrent>
//#include".\xlsxdocument.h"
//#include".\xlsxworkbook.h"
#include".\Qt5Xlsx\xlsxdocument.h" #include".\Qt5Xlsx\xlsxdocument.h"
#include".\Qt5Xlsx\xlsxworkbook.h" #include".\Qt5Xlsx\xlsxworkbook.h"
@ -23,6 +21,7 @@
#include "QNumTemplateBuild.h" #include "QNumTemplateBuild.h"
#include "ui_SmokeBoxIdentification.h" #include "ui_SmokeBoxIdentification.h"
//#define IMAGEDRAWING OPENCV //#define IMAGEDRAWING OPENCV
#define IMAGEDRAWING LPV #define IMAGEDRAWING LPV
@ -68,9 +67,18 @@ struct EmptyCheckInfo
struct StockCheckInfo struct StockCheckInfo
{ {
// "SC&6&UL062015020111&6335&37010106&30&N>" // "SC&6&UL062015020111&6335&37010106&30&N>"
// 新规则GP&111&6&2121&1&S001&25>
// 111:ID号
// 6:巷道号
// 2121:任务号-工单号
// 1方向1左2右
// S001:品规号-上位机发送的品规号
//
QString streetName; // 巷道6 QString streetName; // 巷道6
QString taskNum; // 工单号6335 QString taskNum; // 工单号6335
QString stockNum; // 货架位置UL062015020111 6号堆垛机2右边 QString stockNum; // 货架位置UL062015020111 6号堆垛机2右边
QString id = 0;
QString stockLocation = 0; // 方向1左2右0保留为之前规则
QString smokeTypeNum; //上位机发送的品规号37010106 QString smokeTypeNum; //上位机发送的品规号37010106
QString smokeQuantity; //上位机发送的数量30 QString smokeQuantity; //上位机发送的数量30
QString smokeTypeNumRlt; //盘点识别的品规号 QString smokeTypeNumRlt; //盘点识别的品规号
@ -99,6 +107,10 @@ struct StockCheckInfo
// this->correctness = obj.correctness; // this->correctness = obj.correctness;
// return *this; // return *this;
//} //}
}; };
@ -169,9 +181,10 @@ private:
void moduleLoading(); void moduleLoading();
ModuleParam m_moduleParam; ModuleParam m_moduleParam;
QMap<QString, QString> m_mapSmokeCode2Name; QMap<QString, QString> m_mapSmokeCode2Name;
QMap<QString, QString> m_mapSmokeName2TemplateFolderName; QMap<QString, QString> m_mapSmokeName2TemplateFolderName;

@ -13,6 +13,14 @@
#include "QZkJsonParser.h" #include "QZkJsonParser.h"
#include "lp_singleton.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 DELETE_POINTER(p) if (p) {delete p; p = NULL;}
#define MODULE_CONFIG "\\config\\module.json" #define MODULE_CONFIG "\\config\\module.json"
@ -20,6 +28,9 @@
#define NET_CONFIG "\\config\\netSetting.json" #define NET_CONFIG "\\config\\netSetting.json"
#define COM_CONFIG "\\config\\comSetting.json" #define COM_CONFIG "\\config\\comSetting.json"
#define MATCHER_CONFIG "\\config\\match.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 SMOKEINFO_XLSX_CONFIG "\\user\\smokeInfo.xlsx"
#define FILE_STORAGE_PATH ".\\fileData" #define FILE_STORAGE_PATH ".\\fileData"
@ -39,6 +50,7 @@
#define CODE_CONTENT_SPLIT "," #define CODE_CONTENT_SPLIT ","
#define CONTENT_SPLIT ";" #define CONTENT_SPLIT ";"
#define END_SYMBOL ">" #define END_SYMBOL ">"
#define START_CAPTURE "GP"
#define LP_COLOR_CONTROL 0x88 #define LP_COLOR_CONTROL 0x88
#define LP_D1TOD80 0x86 #define LP_D1TOD80 0x86
@ -119,8 +131,8 @@ struct debugMsg
enum eCameraLocation enum eCameraLocation
{ {
emSide=0, emSide=0, // 代表真正有效采集的相机
emTop emTop // 代表闲置的相机
}; };
enum eSideID { enum eSideID {

@ -1,50 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QModuleChoiceClass</class>
<widget class="QWidget" name="QModuleChoiceClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>190</width>
<height>111</height>
</rect>
</property>
<property name="windowTitle">
<string>QModuleChoice</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox_2">
<property name="text">
<string>扫码器</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>传感器</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>请选择应用的模块:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>确定</string>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

Loading…
Cancel
Save