فهرست منبع

Merge pull request #9 from dongxuecheng/dxc/basic_frame

修改bug
Xuecheng Dong 7 ماه پیش
والد
کامیت
722bf1c586
2فایلهای تغییر یافته به همراه22 افزوده شده و 11 حذف شده
  1. 20 9
      compressed_oxygen_detect.py
  2. 2 2
      globals.py

+ 20 - 9
compressed_oxygen_detect.py

@@ -62,35 +62,46 @@ def process_video(model_path, video_source, start_event):
                 confidences = r.boxes.conf  # 提取所有检测到的置信度
                 classes = r.boxes.cls  # 提取所有检测到的类别索引
 
-                head_box=[]
-                hand_box=[]
+                head_box=[0,0,0,0]
+                hand_box=[0,0,0,0]
                 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]
-                    print("label:",label)
+                    #print("label:",label)
 
                     if(label=='head'):head_box=[x1,y1,x2,y2]
                     if(label=='hand'):hand_box=[x1,y1,x2,y2]
 
                     if(label=='aerostat_gasbag'):
                         steps[0]=True
-                        if(IoU(head_box,[x1,y1,x2,y2])>0.1):steps[2]=True
+                        print("steps[0]:",steps[0])
+                        if(IoU(head_box,[x1,y1,x2,y2])>0.1):
+                            steps[2]=True
+                            print("steps[2]:",steps[2])
 
                     if(label=='neckband'):
-                        if(IoU(head_box,[x1,y1,x2,y2])>0.1):steps[1]=True
+                        if(IoU(head_box,[x1,y1,x2,y2])>0.1):
+                            steps[1]=True
+                            print("steps[1]:",steps[1])
 
 
                     if(label=='valve'):
-                        if(IoU(hand_box,[x1,y1,x2,y2])>0.1):steps[2]=True
+                        if(IoU(hand_box,[x1,y1,x2,y2])>0.1):
+                            steps[2]=True
+                            print("steps[2]:",steps[2])
                     
                     if(label=='air make-up'):
                         steps[0]=True
-                        if(IoU(hand_box,[x1,y1,x2,y2])>0.1):steps[4]=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
+                        if(IoU(head_box,[x1,y1,x2,y2])>0.1):
+                            steps[5]=True
+                            print("steps[5]:",steps[5])
                 
 
                 for i, step in enumerate(steps):

+ 2 - 2
globals.py

@@ -12,8 +12,8 @@ lock=threading.Lock()
 ###############焊接考核
 #为True时,表示某一步骤完成,并保存图片post
 steps = [False] * 6
-head_box=[]
-hand_box=[]
+head_box=[0,0,0,0]
+hand_box=[0,0,0,0]
 # 压缩氧
 # 1 = 外壳去掉
 # 2 = 脖带戴好