From fad554632e09cc86bb4cab097e5ebaaf9c1ae756 Mon Sep 17 00:00:00 2001 From: martin <1486756632@qq.com> Date: Tue, 24 Mar 2026 17:44:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=B1=BB=E5=88=AB=E8=AE=A1?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme | 2 +- yolo/cv_multi_model_back_video.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/readme b/readme index 642aa5d..0373ee6 100644 --- a/readme +++ b/readme @@ -1,4 +1,4 @@ -conda create -n aienv2 python=3.10 +conda create -n test_sahi python=3.10 激活环境 conda create -n yolo_trt_10 python=3.10 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ --override-channels diff --git a/yolo/cv_multi_model_back_video.py b/yolo/cv_multi_model_back_video.py index ab83240..561583f 100644 --- a/yolo/cv_multi_model_back_video.py +++ b/yolo/cv_multi_model_back_video.py @@ -3317,6 +3317,9 @@ async def send_frame_to_s3_mq(loop,upload_executor,task_id, mqtt, mqtt_topic, ca para = { "category": 3 } + local_track_id_list=[] + local_key_id_list=[] + local_key_count_list = [] target_location_back = [] # 本地缓存,用作位置重复计算 current_time_second = int(time.time()) repeat_time_count = 0 @@ -3390,6 +3393,17 @@ async def send_frame_to_s3_mq(loop,upload_executor,task_id, mqtt, mqtt_topic, ca track_id = item["track_id"] new_track_id = item["new_track_id"] + if track_id not in local_track_id_list: + local_track_id_list.append(track_id) + + if cls_id in local_key_id_list: + first_index = local_key_id_list.index(cls_id) # 获取 key_id 的第一个下标 + local_key_count_list[first_index]=local_key_count_list[first_index]+1 + else: + local_key_id_list.append(cls_id) + local_key_count_list.append(1) + + # should_report = True # # 如果这个track_id已经上报过,检查是否超过上报间隔 @@ -3472,6 +3486,16 @@ async def send_frame_to_s3_mq(loop,upload_executor,task_id, mqtt, mqtt_topic, ca model_cls = model_para.get("model_cls_index", {}) list_func_id = model_para.get("model_list_func_id", -11) func_id = model_para.get("func_id", []) + count_message=[] + for k,v in chinese_label.items(): + if int(k) in local_key_id_list: + k_index=local_key_id_list.index(int(k)) + clss_count=local_key_count_list[k_index] + count_message.append({ + "cls_index":k_index, + "cls_name":v, + "count":clss_count + }) # 获取DRC消息(同步操作,放到线程池) local_drc_message = await loop.run_in_executor(upload_executor, get_local_drc_message) @@ -3535,6 +3559,7 @@ async def send_frame_to_s3_mq(loop,upload_executor,task_id, mqtt, mqtt_topic, ca "longitude": cam_longitude, "latitude": cam_latitude }, + "count_message":count_message, "des_location":des_location_result } await event_queue.put({