Sfoglia il codice sorgente

完成单人吊具后端

dxc 8 mesi fa
parent
commit
7a93c7a6db
5 ha cambiato i file con 396 aggiunte e 14 eliminazioni
  1. 105 0
      app6.py
  2. 44 5
      basket_cleaning_detect.py
  3. 41 8
      config.py
  4. 202 0
      equipment_cleaning_detect.py
  5. 4 1
      globals.py

+ 105 - 0
app6.py

@@ -0,0 +1,105 @@
+import re
+import threading
+import time
+from flask import Flask, jsonify,send_from_directory
+#from basket_cleaning_detect import start_basket_cleaning_detection,init_basket_cleaning_detection
+from equipment_cleaning_detect import start_equipment_cleaning_detection,init_equipment_cleaning_detection
+from globals import inference_thread, stop_event,redis_client
+
+
+app = Flask(__name__)
+
+
+# Define the /wearing_detection endpoint
+
+@app.route('/equipment_cleaning_detection', methods=['GET'])
+def equipment_cleaning_detection():#开启平台搭设检测
+    global inference_thread#当全局变量需要重新赋值时,需要用global关键字声明
+
+    if inference_thread is None or not inference_thread.is_alive():#防止重复开启检测服务
+        #redis_client.set("log_in_flag",'False')
+
+        stop_event.clear()
+
+        start_events = []#给每个线程一个事件,让我知道某个线程是否开始检测
+        inference_thread = threading.Thread(target=start_equipment_cleaning_detection,args=(start_events,))
+        inference_thread.start()
+        
+            
+        app.logger.info('start_equipment_cleaning_detection')
+        init_equipment_cleaning_detection()
+
+
+        # 等待所有YOLO线程开始检测
+        for event in start_events:
+            event.wait()
+
+        return jsonify({"status": "SUCCESS"}), 200
+    
+    else:
+        app.logger.info("reset_detection already running")   
+        return jsonify({"status": "ALREADY_RUNNING"}), 200    
+
+@app.route('/equipment_cleaning_status', methods=['GET']) 
+def equipment_cleaning_status():#获取平台搭设状态状态
+    if not redis_client.exists('equipment_cleaning_order'):#平台搭设步骤还没有一个完成
+        app.logger.info('equipment_cleaning_order is none')
+
+        return jsonify({"status": "NONE"}), 200
+    
+    else:
+
+        basket_cleaning_order = redis_client.lrange("equipment_cleaning_order", 0, -1)
+
+        json_array = []
+        for value in basket_cleaning_order:
+            match = re.search(r'equipment_step_(\d+)', value)
+            step_number = match.group(1)
+            json_object = {"step": step_number, "image": redis_client.get(f"equipment_step_{step_number}")}
+            json_array.append(json_object) 
+
+        return jsonify({"status": "SUCCESS","data":json_array}), 200
+
+
+@app.route('/basket_cleaning_finish', methods=['GET']) 
+def equipment_cleaning_finish():#开始登录时,检测是否需要复位,若需要,则发送复位信息,否则开始焊接检测
+
+    stop_inference_internal()
+    app.logger.info('bequipment_cleaning_order')
+    return jsonify({"status": "SUCCESS"}), 200
+
+
+    
+def stop_inference_internal():
+    global inference_thread
+    if inference_thread is not None and inference_thread.is_alive():
+        stop_event.set()  # 设置停止事件标志,通知推理线程停止运行
+        inference_thread.join()  # 等待推理线程结束
+        inference_thread = None  # 释放线程资源
+        app.logger.info('detection stopped')
+        return True
+    else:
+        app.logger.info('No inference stopped')
+        return False
+
+@app.route('/stop_detection', methods=['GET'])
+def stop_inference():
+    #global inference_thread
+    if stop_inference_internal():
+        app.logger.info('detection stopped')
+        return jsonify({"status": "DETECTION_STOPPED"}), 200
+    else:
+        app.logger.info('No_detection_running')
+        return jsonify({"status": "No_detection_running"}), 200
+
+
+@app.route('/images/<filename>')
+def get_image(filename):
+    app.logger.info('get_image'+filename)
+    return send_from_directory('static/images', filename)
+
+
+if __name__ == '__main__':
+
+    # Start the Flask server
+    app.run(debug=False, host='172.16.20.163', port=5006)

+ 44 - 5
basket_cleaning_detect.py

@@ -66,9 +66,14 @@ def save_image_and_redis(redis_client, results, step_name, save_path, post_path)
     elif step_name == "basket_step_3":
         annotated_frame = cv2.polylines(annotated_frame, [region.reshape(-1, 1, 2) for region in BASKET_STEEL_WIRE_REGION], isClosed=True, color=(0, 255, 0), thickness=4)
     elif step_name == "basket_step_4":
-        annotated_frame = cv2.polylines(annotated_frame, BASKET_PLATFORM_REGION.reshape(-1, 1, 2), isClosed=True, color=(0, 255, 0), thickness=4)
+        annotated_frame = cv2.polylines(annotated_frame, [BASKET_PLATFORM_REGION.reshape(-1, 1, 2)], isClosed=True, color=(0, 255, 0), thickness=4)
+        #cv2.fillPoly(annotated_frame, [BASKET_PLATFORM_REGION], (0, 255, 0))#填充区域
+    elif step_name == "basket_step_5":
+        annotated_frame = cv2.polylines(annotated_frame, [region.reshape(-1, 1, 2) for region in BASKET_LIFTING_REGION], isClosed=True, color=(0, 255, 0), thickness=4)
     elif step_name == "basket_step_6":
         annotated_frame = cv2.polylines(annotated_frame, [region.reshape(-1, 1, 2) for region in BASKET_SAFETY_LOCK_REGION], isClosed=True, color=(0, 255, 0), thickness=4)
+    elif step_name == "basket_step_7":
+        annotated_frame = cv2.polylines(annotated_frame, [BASKET_ELECTRICAL_SYSTEM_REGION.reshape(-1, 1, 2)], isClosed=True, color=(0, 255, 0), thickness=4)
     
     cv2.imwrite(imgpath, annotated_frame)
     redis_client.set(step_name, post_path)
@@ -109,10 +114,8 @@ def process_video(model_path, video_source,start_event):
 
             results = model.predict(frame,conf=0.6,verbose=False)
 
-            
-
-
             global basket_suspension_flag,basket_warning_zone_flag,basket_steel_wire_flag,basket_platform_flag,basket_electrical_system_flag,basket_lifting_flag,basket_safety_lock_flag,basket_safety_belt_flag,basket_cleaning_up_flag,basket_cleaning_operation_flag,basket_empty_load_flag,basket_person_flag
+            global BASKET_PLATFORM_REGION,BASKET_LIFTING_REGION,BASKET_ELECTRICAL_SYSTEM_REGION
             for r in results:
                 if model_path==BASKET_CLEANING_MODEL_SOURCES[0] and not basket_suspension_flag:#D4悬挂机构
                     boxes=r.boxes.xyxy#人体的检测框
@@ -194,7 +197,7 @@ def process_video(model_path, video_source,start_event):
                     if not basket_person_flag and get_region_mean_color([BASKET_EMPTY_LOAD_REGION], frame):
                         basket_empty_load_flag=True 
                     
-                else:#d6目标检测
+                elif model_path==BASKET_CLEANING_MODEL_SOURCES[3]:#d6目标检测
                     boxes = r.boxes.xyxy  
                     confidences = r.boxes.conf 
                     classes = r.boxes.cls  
@@ -211,6 +214,42 @@ def process_video(model_path, video_source,start_event):
                             is_inside = any(point_in_region(point,BASKET_CLEANING_OPERATION_REGION) for point in points)
                             if is_inside:
                                 basket_cleaning_operation_flag=True
+                else:
+                    boxes = r.boxes.xyxy
+                    masks = r.masks.xy
+                    classes = r.boxes.cls 
+                    hoist=[]
+                    for i in range(len(boxes)):
+                        x1, y1, x2, y2 = boxes[i].tolist()
+                        cls = int(classes[i].item())
+                        label = model.names[cls]
+                        if label=="basket":
+                            BASKET_PLATFORM_REGION = np.array(masks[i].tolist(), np.int32)
+                        elif label=="hoist":
+                            #hoist.append(masks[i].tolist())
+                            #hoist.append(np.array(masks[i].tolist(), np.int32))
+                            # print(masks[i].tolist())
+                            BASKET_LIFTING_REGION = np.array(masks[i].tolist(),np.int32)
+                            #pass
+                            #TODO
+
+                        elif label=="electricalSystem":
+                            BASKET_ELECTRICAL_SYSTEM_REGION = np.array(masks[i].tolist(), np.int32)
+                    
+                    # 检查是否所有hoist masks具有相同形状
+                    # if all(h.shape == hoist[0].shape for h in hoist):
+                    #     BASKET_LIFTING_REGION = np.vstack(hoist)  # 堆叠成二维数组
+                    # else:
+                    #     # 如果形状不同,可以手动处理,比如补齐/裁剪
+                    #     # 这里假设你想补齐到最大的形状
+                    #     max_shape = max(h.shape for h in hoist)
+                    #     padded_hoist = [np.pad(h, ((0, max_shape[0] - h.shape[0]), (0, max_shape[1] - h.shape[1])), mode='constant') for h in hoist]
+                    #     BASKET_LIFTING_REGION = np.array(padded_hoist)
+                    #BASKET_LIFTING_REGION = np.array(hoist,np.int32)
+                    #print("hoist",hoist.shape)
+
+                            
+
 
             if model_path==BASKET_CLEANING_MODEL_SOURCES[0] and not redis_client.exists("basket_step_2") and basket_suspension_flag:#D4悬挂机构 
                 save_image_and_redis(redis_client, results, "basket_step_2", SAVE_IMG_PATH, POST_IMG_PATH5)

+ 41 - 8
config.py

@@ -10,6 +10,7 @@ POST_IMG_PATH2 = 'http://172.16.20.163:5002/images' #焊接考核科目2
 POST_IMG_PATH3 = 'http://172.16.20.163:5003/images' #平台搭设科目1,劳保穿戴
 POST_IMG_PATH4 = 'http://172.16.20.163:5004/images' #平台搭设科目2,搭建和拆除
 POST_IMG_PATH5 = 'http://172.16.20.163:5005/images'#吊篮清洗
+POST_IMG_PATH5 = 'http://172.16.20.163:5006/images'#吊具清洗
 
 #焊接考核视频流
 # Define paths to RTSP streams
@@ -104,6 +105,7 @@ BASKET_CLEANING_CH4_POSE_MODEL='/mnt/xcd/code/ai_test/weights/yolov8s-pose1.pt'
 BASKET_CLEANING_CH5_DETECT_MODEL='/mnt/xcd/code/ai_test/weights/yolov8s1.pt'
 BASKET_CLEANING_CH6_POSE_MODEL='/mnt/xcd/code/ai_test/weights/yolov8s-pose2.pt'
 BASKET_CLEANING_CH6_DETECT_MODEL='/mnt/xcd/code/ai_test/weights/yolov8s2.pt'
+BASKET_CLEANING_CH6_SEG_MODEL='/mnt/xcd/code/ai_test/weights/basket_seg.pt'
 
 BASKET_CLEANING_CH4_RTSP='rtsp://admin:yaoan1234@172.16.22.237/cam/realmonitor?channel=1&subtype=0'
 BASKET_CLEANING_CH5_RTSP='rtsp://admin:yaoan1234@172.16.22.239/cam/realmonitor?channel=1&subtype=0'
@@ -112,12 +114,14 @@ BASKET_CLEANING_CH6_RTSP='rtsp://admin:yaoan1234@172.16.22.242/cam/realmonitor?c
 BASKET_CLEANING_VIDEO_SOURCES=[BASKET_CLEANING_CH4_RTSP,
                                BASKET_CLEANING_CH5_RTSP,
                                BASKET_CLEANING_CH6_RTSP,
+                               BASKET_CLEANING_CH6_RTSP,
                                BASKET_CLEANING_CH6_RTSP]
 
 BASKET_CLEANING_MODEL_SOURCES=[BASKET_CLEANING_CH4_POSE_MODEL,
                                BASKET_CLEANING_CH5_DETECT_MODEL,
                                BASKET_CLEANING_CH6_POSE_MODEL,
-                               BASKET_CLEANING_CH6_DETECT_MODEL]
+                               BASKET_CLEANING_CH6_DETECT_MODEL,
+                               BASKET_CLEANING_CH6_SEG_MODEL]
 
 #
 
@@ -135,16 +139,45 @@ BASKET_STEEL_WIRE_REGION = np.array([
     # [(1293, 0), (1867, 935), (1904, 906), (1354, 9)],  # 左边多边形区域
 ], np.int32)#钢丝绳区域,暂时没有钢丝绳的区域
 
-BASKET_PLATFORM_REGION = np.array([[450, 935], [370, 1275], [1685, 1350], [1600, 720]], np.int32)
-BASKET_LIFTING_REGION = np.array([
-    [[1275, 975], [1270, 1160], [1500, 1160], [1480, 975]],
-    [[570, 1015], [560, 1150], [820, 1190], [832, 1060]]
-],np.int32)
+BASKET_PLATFORM_REGION = np.array([], np.int32)
+BASKET_LIFTING_REGION = np.array([]
+,np.int32)
 
 BASKET_SAFETY_LOCK_REGION = np.array([
     [[1635, 813], [1742, 927], [1955, 910], [1906, 747]],
     [[650, 944], [800, 1000], [800, 923], [680, 872]]
     ], np.int32)
-BASKET_ELECTRICAL_SYSTEM_REGION = np.array([[950, 680], [930, 880], [1360, 910], [1250, 660]], np.int32)
+BASKET_ELECTRICAL_SYSTEM_REGION = np.array([], np.int32)
 BASKET_CLEANING_OPERATION_REGION = np.array([[668, 310], [800, 310], [800, 1070], [668, 1070]], np.int32)
-BASKET_EMPTY_LOAD_REGION = np.array([(752, 855), (712, 969), (836, 1020), (896, 918)], np.int32)
+BASKET_EMPTY_LOAD_REGION = np.array([(752, 855), (712, 969), (836, 1020), (896, 918)], np.int32)
+
+
+#单人吊具
+EQUIPMENT_CLEANING_CH3_RTSP='rtsp://admin:yaoan1234@172.16.22.238/cam/realmonitor?channel=1&subtype=0'
+EQUIPMENT_CLEANING_CH8_RTSP='rtsp://admin:yaoan1234@172.16.22.44/cam/realmonitor?channel=1&subtype=0'
+
+
+EQUIPMENT_CLEANING_CH3_DETECT_MODEL='/mnt/xcd/code/ai_test/weights/yolov8s1.pt'
+EQUIPMENT_CLEANING_CH8_POSE_MODEL='/mnt/xcd/code/ai_test/weights/yolov8s-pose2.pt'
+EQUIPMENT_CLEANING_CH8_DETECT_MODEL='/mnt/xcd/code/ai_test/weights/yolov8s2.pt'
+
+EQUIPMENT_CLEANING_VIDEO_SOURCES=[EQUIPMENT_CLEANING_CH3_RTSP,
+                                  EQUIPMENT_CLEANING_CH8_RTSP,
+                                  EQUIPMENT_CLEANING_CH8_RTSP
+]
+
+EQUIPMENT_CLEANING_MODEL_SOURCES=[EQUIPMENT_CLEANING_CH3_DETECT_MODEL,
+                                  EQUIPMENT_CLEANING_CH8_POSE_MODEL,
+                                  EQUIPMENT_CLEANING_CH8_DETECT_MODEL
+]
+
+EQUIPMENT_ANCHOR_DEVICE_REGION = np.array([
+    [[668, 310], [800, 310], [800, 1070], [668, 1070]],
+], np.int32)
+EQUIPMENT_WORK_ROPE_REGION = np.array([
+    [[668, 310], [800, 310], [800, 1070], [668, 1070]],
+], np.int32)
+EQUIPMENT_SAFETY_ROPE_REGION = np.array([
+    [[668, 310], [800, 310], [800, 1070], [668, 1070]],
+], np.int32)
+EQUIPMENT_CLEANING_OPERATION_REGION=np.array([[668, 310], [800, 310], [800, 1070], [668, 1070]], np.int32)

+ 202 - 0
equipment_cleaning_detect.py

@@ -0,0 +1,202 @@
+import cv2
+import torch
+from shapely.geometry import box, Polygon
+import threading
+import numpy as np
+from datetime import datetime
+from ultralytics import YOLO
+
+from utils.tool import IoU
+from globals import stop_event,redis_client
+from config import SAVE_IMG_PATH,POST_IMG_PATH6,EQUIPMENT_CLEANING_VIDEO_SOURCES,EQUIPMENT_CLEANING_MODEL_SOURCES
+from config import EQUIPMENT_SAFETY_ROPE_REGION,EQUIPMENT_WORK_ROPE_REGION,EQUIPMENT_ANCHOR_DEVICE_REGION,EQUIPMENT_CLEANING_OPERATION_REGION
+from globals import equipment_cleaning_flag
+
+def init_equipment_cleaning_detection():
+    global equipment_cleaning_flag
+    equipment_cleaning_flag=[False]*12
+    
+    for i in range(1, 12):
+        redis_client.delete(f"equipment_step_{i}")
+    redis_client.delete("equipment_cleaning_order")
+
+    pass
+
+def start_equipment_cleaning_detection(start_events):
+    threads = []
+    for model_path, video_source in zip(EQUIPMENT_CLEANING_MODEL_SOURCES,EQUIPMENT_CLEANING_VIDEO_SOURCES):
+        event = threading.Event()
+        start_events.append(event)
+        thread = threading.Thread(target=process_video, args=(model_path, video_source,event))
+        threads.append(thread)
+        thread.daemon=True
+        thread.start()
+        print("单人吊具清洗子线程运行中")
+
+    # Wait for any threads to complete
+    for thread in threads:
+        thread.join()
+        print("单人吊具清洗子线程运行结束")
+
+
+def point_in_region(point, region):#判断点是否在多边形内
+    is_inside = cv2.pointPolygonTest(region.reshape((-1, 1, 2)), point, False)
+    return is_inside >= 0
+
+def save_image_and_redis(redis_client, results, step_name, save_path, post_path):
+
+    save_time = datetime.now().strftime('%Y%m%d_%H%M')
+    imgpath = f"{save_path}/{step_name}_{save_time}.jpg"
+    annotated_frame = results[0].plot()
+    # if step_name == "equipment_step_2":
+    #     annotated_frame = cv2.polylines(annotated_frame, [region.reshape(-1, 1, 2) for region in BASKET_SUSPENSION_REGION], isClosed=True, color=(0, 255, 0), thickness=4)
+    # elif step_name == "equipment_step_3":
+    #     annotated_frame = cv2.polylines(annotated_frame, [region.reshape(-1, 1, 2) for region in BASKET_STEEL_WIRE_REGION], isClosed=True, color=(0, 255, 0), thickness=4)
+    # elif step_name == "equipment_step_4":
+    #     annotated_frame = cv2.polylines(annotated_frame, BASKET_PLATFORM_REGION.reshape(-1, 1, 2), isClosed=True, color=(0, 255, 0), thickness=4)
+    # elif step_name == "equipment_step_6":
+    #     annotated_frame = cv2.polylines(annotated_frame, [region.reshape(-1, 1, 2) for region in BASKET_SAFETY_LOCK_REGION], isClosed=True, color=(0, 255, 0), thickness=4)
+    
+    cv2.imwrite(imgpath, annotated_frame)
+    redis_client.set(step_name, post_path)
+    redis_client.rpush("equipment_cleaning_order", step_name)
+
+
+
+
+def process_video(model_path, video_source,start_event):
+    model = YOLO(model_path)
+    cap = cv2.VideoCapture(video_source)
+    
+    #cap.set(cv2.CAP_PROP_BUFFERSIZE, 100)  # 设置缓冲区大小为 10 帧    
+    while cap.isOpened():
+        if stop_event.is_set():#控制停止推理
+            break
+
+        success, frame = cap.read()
+        if success:
+            # Run YOLOv8 inference on the frame
+            if cap.get(cv2.CAP_PROP_POS_FRAMES) % 25 != 0:
+                continue
+
+            results = model.predict(frame,conf=0.6,verbose=False)
+            global equipment_cleaning_flag
+
+            for r in results:
+                if model_path==EQUIPMENT_CLEANING_MODEL_SOURCES[0]:#D3 detect
+                    boxes = r.boxes.xyxy  
+                    confidences = r.boxes.conf 
+                    classes = r.boxes.cls  
+                
+                    # basket_warning_zone_flag=False#当检测不到则为False
+                    # basket_cleaning_up_flag=False
+                    equipment_cleaning_flag[0]=False
+                    for i in range(len(boxes)):
+                        x1, y1, x2, y2 = boxes[i].tolist()
+                        confidence = confidences[i].item()
+                        cls = int(classes[i].item())
+                        label = model.names[cls]
+                        if label=='warning_zone':
+                            equipment_cleaning_flag[0]=True
+                        elif label=='person':
+                            centerx=(x1+x2)/2
+                            centery=(y1+y2)/2
+                            point_in_region_flag=point_in_region([centerx,centery],EQUIPMENT_ANCHOR_DEVICE_REGION)#挂点装置是否检测到人
+                            if point_in_region_flag:
+                                equipment_cleaning_flag[1]=True
+                        elif label=='seating_plate':
+                            equipment_cleaning_flag[2]=True
+                        elif label=='self_locking':
+                            equipment_cleaning_flag[5]=True
+                            equipment_cleaning_flag[6]=True
+                        elif label=='brush':
+                            equipment_cleaning_flag[10]=True
+                        elif not equipment_cleaning_flag[0]:#当检测不到警戒区时,判定未拆除警戒区域
+                            equipment_cleaning_flag[11]=True
+                            
+                elif model_path==EQUIPMENT_CLEANING_MODEL_SOURCES[1]:#D8,pose
+                    boxes=r.boxes.xyxy#人体的检测框
+                    keypoints = r.keypoints.xy  
+                    confidences = r.keypoints.conf  
+
+                    basket_person_flag=False#当检测不到则为False
+                    for i in range(len(boxes)):
+                        #当有检测框,则说明有人
+                        #basket_person_flag=True
+                        left_wrist, right_wrist = keypoints[i][9:11].tolist()#获取左右手腕和左右肘的坐标
+                        points = [left_wrist, right_wrist]
+                        if not equipment_cleaning_flag[3]:
+                            is_inside1 = any(point_in_region(point, EQUIPMENT_WORK_ROPE_REGION[0]) for point in points)
+                            if is_inside1:
+                                equipment_cleaning_flag[3]=True#工作绳
+                                print("工作绳")
+                        if not equipment_cleaning_flag[4]:
+                            is_inside = any(point_in_region(point, EQUIPMENT_SAFETY_ROPE_REGION) for point in points)
+                            if is_inside:
+                                equipment_cleaning_flag[4]=True#安全绳
+                                print("安全绳")
+
+                    
+                else:#d8 目标检测
+                    boxes = r.boxes.xyxy  
+                    confidences = r.boxes.conf 
+                    classes = r.boxes.cls  
+
+                    #basket_safety_lock_flag=False#当检测不到则为False
+                    for i in range(len(boxes)):
+                        x1, y1, x2, y2 = boxes[i].tolist()
+                        confidence = confidences[i].item()
+                        cls = int(classes[i].item())
+                        label = model.names[cls]
+                        if label=='safety_belt':
+                            equipment_cleaning_flag[8]=True
+                        elif label=='brush':
+                            is_inside = any(point_in_region(point,EQUIPMENT_CLEANING_OPERATION_REGION) for point in points)#刷子是否在指定区域
+                            if is_inside:
+                                equipment_cleaning_flag[9]=True
+
+            if model_path==EQUIPMENT_CLEANING_MODEL_SOURCES[0]:
+                if equipment_cleaning_flag[0] and not redis_client.exists("equipment_step_1"):
+                    save_image_and_redis(redis_client, results, "equipment_step_1", SAVE_IMG_PATH, POST_IMG_PATH6)
+                if equipment_cleaning_flag[1] and not redis_client.exists("equipment_step_2"):
+                    save_image_and_redis(redis_client, results, "equipment_step_2", SAVE_IMG_PATH, POST_IMG_PATH6)
+                if equipment_cleaning_flag[2] and not redis_client.exists("equipment_step_3"):
+                    save_image_and_redis(redis_client, results, "equipment_step_3", SAVE_IMG_PATH, POST_IMG_PATH6)
+                if equipment_cleaning_flag[5] and not redis_client.exists("equipment_step_6"):
+                    save_image_and_redis(redis_client, results, "equipment_step_6", SAVE_IMG_PATH, POST_IMG_PATH6)
+                if equipment_cleaning_flag[10] and not redis_client.exists("equipment_step_11"):
+                    save_image_and_redis(redis_client, results, "equipment_step_11", SAVE_IMG_PATH, POST_IMG_PATH6)
+                if equipment_cleaning_flag[11] and not redis_client.exists("equipment_step_12"):
+                    save_image_and_redis(redis_client, results, "equipment_step_12", SAVE_IMG_PATH, POST_IMG_PATH6)
+                
+
+            elif model_path==EQUIPMENT_CLEANING_MODEL_SOURCES[1]:
+                if equipment_cleaning_flag[3] and not redis_client.exists("equipment_step_4"):
+                    save_image_and_redis(redis_client, results, "equipment_step_4", SAVE_IMG_PATH, POST_IMG_PATH6)
+                if equipment_cleaning_flag[4] and not redis_client.exists("equipment_step_5"):
+                    save_image_and_redis(redis_client, results, "equipment_step_5", SAVE_IMG_PATH, POST_IMG_PATH6)
+                
+            else:#d6目标检测
+
+                if equipment_cleaning_flag[8] and not redis_client.exists("equipment_step_9"):
+                    save_image_and_redis(redis_client, results, "equipment_step_9", SAVE_IMG_PATH, POST_IMG_PATH6)
+                if equipment_cleaning_flag[9] and not redis_client.exists("equipment_step_10"):
+                    save_image_and_redis(redis_client, results, "equipment_step_10", SAVE_IMG_PATH, POST_IMG_PATH6)
+
+
+            start_event.set()          
+        else:
+            # Break the loop if the end of the video is reached
+            break
+
+    # Release the video capture object and close the display window
+    cap.release()
+    if torch.cuda.is_available():
+        torch.cuda.empty_cache()
+    del model
+
+
+
+        
+
+    

+ 4 - 1
globals.py

@@ -87,4 +87,7 @@ basket_empty_load_flag=False#吊篮空载
 basket_safety_belt_flag=False#吊篮安全带挂设
 
 basket_cleaning_operation_flag=False#吊篮清洗操作,检查刷子是否在指定区域
-basket_cleaning_up_flag=False#吊篮清理现场
+basket_cleaning_up_flag=False#吊篮清理现场
+
+#单人吊具
+equipment_cleaning_flag=[False]*12