Pārlūkot izejas kodu

修改后端逻辑

dxc 7 mēneši atpakaļ
vecāks
revīzija
aa9492ccfd
4 mainītis faili ar 36 papildinājumiem un 17 dzēšanām
  1. 1 0
      .gitignore
  2. 33 16
      compressed_oxygen_detect.py
  3. 1 1
      config.py
  4. 1 0
      globals.py

+ 1 - 0
.gitignore

@@ -1,3 +1,4 @@
+weights/
 # Byte-compiled / optimized / DLL files
 __pycache__/
 *.py[cod]

+ 33 - 16
compressed_oxygen_detect.py

@@ -64,6 +64,8 @@ def process_video(model_path, video_source, start_event):
 
                 head_box=[0,0,0,0]
                 hand_box=[0,0,0,0]
+                step4_flag=False
+                air_make_up_flag=False
                 for i in range(len(boxes)):
                     x1, y1, x2, y2 = boxes[i].tolist()
                     confidence = confidences[i].item()
@@ -75,35 +77,50 @@ def process_video(model_path, video_source, start_event):
                     if(label=='hand'):hand_box=[x1,y1,x2,y2]
 
                     if(label=='aerostat_gasbag'):
-                        steps[0]=True
-                        print("steps[0]:",steps[0])
-                        if(IoU(head_box,[x1,y1,x2,y2])>0.1):
+                        if steps[0]==False:
+                            steps[0]=True
+                            print("steps[0]:",steps[0])
+
+                        if(IoU(head_box,[x1,y1,x2,y2])>0 and steps[2]==False):
                             steps[2]=True
                             print("steps[2]:",steps[2])
+                        if(IoU(hand_box,[x1,y1,x2,y2])>0 and steps[4]==False):
+                            step4_flag=True
+                            #steps[4]=True
+                            #print("steps[4]:",steps[4])
 
                     if(label=='neckband'):
-                        if(IoU(head_box,[x1,y1,x2,y2])>0.1):
+                        
+                        if(IoU(head_box,[x1,y1,x2,y2])>0 and steps[1]==False):
                             steps[1]=True
                             print("steps[1]:",steps[1])
 
 
                     if(label=='valve'):
-                        if(IoU(hand_box,[x1,y1,x2,y2])>0.1):
-                            steps[2]=True
-                            print("steps[2]:",steps[2])
+                        if(IoU(hand_box,[x1,y1,x2,y2])>0 and steps[3]==False):
+                            steps[3]=True
+                            print("steps[3]:",steps[3])
                     
                     if(label=='air make-up'):
-                        steps[0]=True
-                        if(IoU(hand_box,[x1,y1,x2,y2])>0.1):
-                            steps[4]=True
-                            print("steps[4]:",steps[4])
-
-                    if(label=='nose clip'):
-                        if(IoU(head_box,[x1,y1,x2,y2])>0.1):
-                            steps[5]=True
-                            print("steps[5]:",steps[5])
+                        air_make_up_flag=True
+                        if steps[0]==False:
+                            steps[0]=True
+                            print("steps[0]:",steps[0])
+
+
+
+                    if(label=='nose clip' and steps[5]==False):
+                        steps[5]=True
+                        print("steps[5]:",steps[5])
                 
+                if step4_flag and air_make_up_flag :
+                    steps[4]=True
+                    print("steps[4]:",steps[4])
 
+                if IoU(head_box,hand_box)>0.5 and steps[5]==False:
+                    steps[5]=True
+                    print("steps[5]:",steps[5])
+                    
                 for i, step in enumerate(steps):
                     if step and redis_client.get(f"compressed_oxygen_step_{i+1}")=='False':
                         redis_client.rpush("compressed_oxygen_order", f"{i+1}")

+ 1 - 1
config.py

@@ -8,7 +8,7 @@
 # POST_IMG_PATH1 = 'http://172.16.20.163:5001/images'  # 通过端口映射post发送能够访问的位置 焊接考核科目1
 # POST_IMG_PATH2 = 'http://172.16.20.163:5002/images' #焊接考核科目2
 
-VIDEO_SOURCE = 'rtsp://admin:yaoan1234@192.169.1.114/cam/realmonitor?channel=1&subtype=0'  # 视频源路径
+VIDEO_SOURCE = 'rtsp://admin:yaoan1234@192.168.1.114/cam/realmonitor?channel=1&subtype=0'  # 视频源路径
 #焊接考核视频流
 # Define paths to RTSP streams
 

+ 1 - 0
globals.py

@@ -14,6 +14,7 @@ lock=threading.Lock()
 steps = [False] * 6
 head_box=[0,0,0,0]
 hand_box=[0,0,0,0]
+
 # 压缩氧
 # 1 = 外壳去掉
 # 2 = 脖带戴好