diff --git a/README.md b/README.md index e22f461..22ad78b 100644 --- a/README.md +++ b/README.md @@ -25,4 +25,18 @@ ### nginx ```angular2html docker run --name nginx -d -p 80:80 --restart always -v /home/unitree/web/nginx.conf:/etc/nginx/nginx.conf -v /home/unitree/web/:/usr/share/nginx/html nginx:stable-alpine-slim -``` \ No newline at end of file +``` + +## 识别内容【待确认】 + +- 10003 疑似第三方施工( 围挡): 15: '施工路牌', 16: '水马', 19: '防护栏', +- 10002 疑似第三方施工( 挖掘机):13: '挖掘机', +- 10004 疑似第三方施工( 施工人员+工程车辆) [6: '人',11: '头', 12: '安全帽',8: '反光衣' ] + [7: '压路机', 10: '土方车', 13: '挖掘机', 14: '推土机',] +- 10005 疑似第三方施工( 围挡、管材等组合类) : 无,没有管材 +- 10001 疑似第三方施工( 管材) : 无,没有管材 +- 10006 第三方施工监测 +- 10007 闸井监测: 0: '井盖', 1: '井盖塌陷', 2: '井盖眼', 3: '井盖破损', 4: '井盖移位', 5: '井盖缺失' +- 10008 引入口监测 +- 10009 调压箱监测 :无 不检测调压箱 +- 10010 实时数据上传 +- 其他识别内容: 9: '土堆' 17: '路锥', 18: '铁锹', 20: '风镐' \ No newline at end of file diff --git a/README.md b/README.md index e22f461..22ad78b 100644 --- a/README.md +++ b/README.md @@ -25,4 +25,18 @@ ### nginx ```angular2html docker run --name nginx -d -p 80:80 --restart always -v /home/unitree/web/nginx.conf:/etc/nginx/nginx.conf -v /home/unitree/web/:/usr/share/nginx/html nginx:stable-alpine-slim -``` \ No newline at end of file +``` + +## 识别内容【待确认】 + +- 10003 疑似第三方施工( 围挡): 15: '施工路牌', 16: '水马', 19: '防护栏', +- 10002 疑似第三方施工( 挖掘机):13: '挖掘机', +- 10004 疑似第三方施工( 施工人员+工程车辆) [6: '人',11: '头', 12: '安全帽',8: '反光衣' ] + [7: '压路机', 10: '土方车', 13: '挖掘机', 14: '推土机',] +- 10005 疑似第三方施工( 围挡、管材等组合类) : 无,没有管材 +- 10001 疑似第三方施工( 管材) : 无,没有管材 +- 10006 第三方施工监测 +- 10007 闸井监测: 0: '井盖', 1: '井盖塌陷', 2: '井盖眼', 3: '井盖破损', 4: '井盖移位', 5: '井盖缺失' +- 10008 引入口监测 +- 10009 调压箱监测 :无 不检测调压箱 +- 10010 实时数据上传 +- 其他识别内容: 9: '土堆' 17: '路锥', 18: '铁锹', 20: '风镐' \ No newline at end of file diff --git a/app.py b/app.py index 8d34327..b6c59c6 100644 --- a/app.py +++ b/app.py @@ -16,6 +16,8 @@ loop = asyncio.get_running_loop() # 获取当前主线程的事件循环 tcp_client = AsyncTCPClient(TCP_SERVER["host"], TCP_SERVER["port"]) + await tcp_client.connect() + cap_upload_http_client = AsyncHTTPClient(HTTP_SERVER["url"], HTTP_SERVER["timeout"]) alarm_upload_http_client = AsyncHTTPClient(HTTP_SERVER["url"], HTTP_SERVER["timeout"]) diff --git a/README.md b/README.md index e22f461..22ad78b 100644 --- a/README.md +++ b/README.md @@ -25,4 +25,18 @@ ### nginx ```angular2html docker run --name nginx -d -p 80:80 --restart always -v /home/unitree/web/nginx.conf:/etc/nginx/nginx.conf -v /home/unitree/web/:/usr/share/nginx/html nginx:stable-alpine-slim -``` \ No newline at end of file +``` + +## 识别内容【待确认】 + +- 10003 疑似第三方施工( 围挡): 15: '施工路牌', 16: '水马', 19: '防护栏', +- 10002 疑似第三方施工( 挖掘机):13: '挖掘机', +- 10004 疑似第三方施工( 施工人员+工程车辆) [6: '人',11: '头', 12: '安全帽',8: '反光衣' ] + [7: '压路机', 10: '土方车', 13: '挖掘机', 14: '推土机',] +- 10005 疑似第三方施工( 围挡、管材等组合类) : 无,没有管材 +- 10001 疑似第三方施工( 管材) : 无,没有管材 +- 10006 第三方施工监测 +- 10007 闸井监测: 0: '井盖', 1: '井盖塌陷', 2: '井盖眼', 3: '井盖破损', 4: '井盖移位', 5: '井盖缺失' +- 10008 引入口监测 +- 10009 调压箱监测 :无 不检测调压箱 +- 10010 实时数据上传 +- 其他识别内容: 9: '土堆' 17: '路锥', 18: '铁锹', 20: '风镐' \ No newline at end of file diff --git a/app.py b/app.py index 8d34327..b6c59c6 100644 --- a/app.py +++ b/app.py @@ -16,6 +16,8 @@ loop = asyncio.get_running_loop() # 获取当前主线程的事件循环 tcp_client = AsyncTCPClient(TCP_SERVER["host"], TCP_SERVER["port"]) + await tcp_client.connect() + cap_upload_http_client = AsyncHTTPClient(HTTP_SERVER["url"], HTTP_SERVER["timeout"]) alarm_upload_http_client = AsyncHTTPClient(HTTP_SERVER["url"], HTTP_SERVER["timeout"]) diff --git a/config.py b/config.py index 1e33aea..b34efef 100644 --- a/config.py +++ b/config.py @@ -47,13 +47,13 @@ ] TCP_SERVER = { - "host": "192.168.123.18", + "host": "127.0.0.1", "port": 8888 } HTTP_SERVER = { - "url": "http://127.0.0.1:8000/test", - "timeout": 5 # 超时重试 + "url": "http://111.198.10.15:11645/algorithm/receiveData", + "timeout": 10 # 超时重试 } MODEL_CLASS = { diff --git a/README.md b/README.md index e22f461..22ad78b 100644 --- a/README.md +++ b/README.md @@ -25,4 +25,18 @@ ### nginx ```angular2html docker run --name nginx -d -p 80:80 --restart always -v /home/unitree/web/nginx.conf:/etc/nginx/nginx.conf -v /home/unitree/web/:/usr/share/nginx/html nginx:stable-alpine-slim -``` \ No newline at end of file +``` + +## 识别内容【待确认】 + +- 10003 疑似第三方施工( 围挡): 15: '施工路牌', 16: '水马', 19: '防护栏', +- 10002 疑似第三方施工( 挖掘机):13: '挖掘机', +- 10004 疑似第三方施工( 施工人员+工程车辆) [6: '人',11: '头', 12: '安全帽',8: '反光衣' ] + [7: '压路机', 10: '土方车', 13: '挖掘机', 14: '推土机',] +- 10005 疑似第三方施工( 围挡、管材等组合类) : 无,没有管材 +- 10001 疑似第三方施工( 管材) : 无,没有管材 +- 10006 第三方施工监测 +- 10007 闸井监测: 0: '井盖', 1: '井盖塌陷', 2: '井盖眼', 3: '井盖破损', 4: '井盖移位', 5: '井盖缺失' +- 10008 引入口监测 +- 10009 调压箱监测 :无 不检测调压箱 +- 10010 实时数据上传 +- 其他识别内容: 9: '土堆' 17: '路锥', 18: '铁锹', 20: '风镐' \ No newline at end of file diff --git a/app.py b/app.py index 8d34327..b6c59c6 100644 --- a/app.py +++ b/app.py @@ -16,6 +16,8 @@ loop = asyncio.get_running_loop() # 获取当前主线程的事件循环 tcp_client = AsyncTCPClient(TCP_SERVER["host"], TCP_SERVER["port"]) + await tcp_client.connect() + cap_upload_http_client = AsyncHTTPClient(HTTP_SERVER["url"], HTTP_SERVER["timeout"]) alarm_upload_http_client = AsyncHTTPClient(HTTP_SERVER["url"], HTTP_SERVER["timeout"]) diff --git a/config.py b/config.py index 1e33aea..b34efef 100644 --- a/config.py +++ b/config.py @@ -47,13 +47,13 @@ ] TCP_SERVER = { - "host": "192.168.123.18", + "host": "127.0.0.1", "port": 8888 } HTTP_SERVER = { - "url": "http://127.0.0.1:8000/test", - "timeout": 5 # 超时重试 + "url": "http://111.198.10.15:11645/algorithm/receiveData", + "timeout": 10 # 超时重试 } MODEL_CLASS = { diff --git a/handle_tcp_command.py b/handle_tcp_command.py index c05d85c..8e4f437 100644 --- a/handle_tcp_command.py +++ b/handle_tcp_command.py @@ -1,6 +1,7 @@ import asyncio import base64 import json +import re import time import cv2 from global_logger import logger @@ -11,7 +12,7 @@ self.camera_processors = camera_processors self.http_client = http_client - async def capture_and_send_current_frame(self, camera_processor, message): + async def capture_and_send_current_frame(self, camera_processor, preset, gas_data, longitude, latitude): """捕获当前帧并通过HTTP发送到后台""" cam_id = camera_processor.cam_id @@ -30,27 +31,29 @@ logger.error(f"摄像头 {cam_id} 编码图像失败") return False - def get_cap_content(message): + def get_cap_content(preset): map = { - "1": ('点1', '完成1'), - "2": ('点2', '完成2'), - "3": ('点3', '完成3'), - "4": ('点4', '完成4'), + "1": ('10006', '第三方施工监测', 1), + "2": ('10007', '闸井监测', 0), + "3": ('10008', '引入口监测', 0), + "4": ('10009', '调压箱监测 ', 0), } - return map.get(str(message).strip(), ('', '')) + return map.get(str(preset), ('', '', 0)) # 构建请求数据 - content, status = get_cap_content(message) + report_type, content, status = get_cap_content(preset) request_data = { - "camera_id": cam_id, - "timestamp": time.time(), - "image": base64.b64encode(jpg_data.tobytes()).decode('utf-8'), - 'content': content, - "status": status + "routeNumber": preset, + "picture": base64.b64encode(jpg_data.tobytes()).decode('utf-8'), + "reportType": report_type, + "reportContent": content, + "isAlarm": status, + "reportValue": gas_data, + "gpsPoints": f'{longitude},{latitude}' } # 发送HTTP请求 - await self.http_client.send(json.dumps(request_data)) + await self.http_client.send([request_data]) logger.info(f"摄像头 {cam_id} 已发送当前帧到后台") return True except Exception as e: @@ -62,8 +65,14 @@ try: logger.info(f"处理TCP命令: {message}") + pattern = r"^(\d+),([^,]+),([^,]+),([^,]+)$" + # 检查是否是捕获图像的命令 - if str(message) in ['1', '2', '3', '4']: # todo + match = re.match(pattern, message.strip()) + if match: + preset, gas_data, longitude, latitude = match.groups() + + logger.debug(f"preset = {preset}, gas_data = {gas_data}, longitude = {longitude}, latitude = {latitude}") # 等待5秒 logger.info(f"收到捕获图像命令,等待5秒...") @@ -71,7 +80,7 @@ # 对所有摄像头执行 for cam_id, processor in self.camera_processors.items(): - await self.capture_and_send_current_frame(processor, message) + await self.capture_and_send_current_frame(processor, preset, gas_data, longitude, latitude) logger.info("图像捕获和发送完成")