添加注释

V0.1.0
杜思睿 2 years ago
parent 32d007f431
commit 8b1dd3637c

@ -116,7 +116,7 @@ class SCRFD():
return srcimg
def face_detection(onnxmodel,image,crop_image,x1,y1,x2,y2,face_flag,count):
# 输入为crop目标检测bbox
mynet = SCRFD(onnxmodel, confThreshold=0.8, nmsThreshold=0.5)
outimg= mynet.detect(crop_image,face_flag,count)
image[y1:y2,x1:x2] = outimg

@ -62,12 +62,14 @@ def analysis_video(source_path,output_path,people_modle_path,face_modle_path,act
# 过滤置信度0.5以下目标
if confidence < 0.5:
continue
# 当类别为巡检
if c.int() == 1:
if XJ_dict['head'] == 0 :
XJ_dict['head'] = count
else:
XJ_dict['tail'] = count
crop_img = frame[b_i[1]:b_i[3],b_i[0]:b_i[2]]
# 人脸检测
frame = face_detection(face_modle_path,frame,crop_img,b_i[0],b_i[1],b_i[2],b_i[3],face_flag,count)
annotator.box_label(b, model_coco.names[int(c)]+str(confidence),(0,0,255))
@ -77,7 +79,6 @@ def analysis_video(source_path,output_path,people_modle_path,face_modle_path,act
for box_a in boxes_a:
b_a = box_a.xyxy[0] # get box coordinates in (x1,y1,x2,y2) format #tensor([ 677.5757, 147.2737, 1182.3381, 707.2565])
c_a = box_a.cls # tensor([0.])
confidence_a = float(box_a.conf)
confidence_a = round(confidence_a, 2)
# 过滤置信度0.5以下目标
@ -87,7 +88,6 @@ def analysis_video(source_path,output_path,people_modle_path,face_modle_path,act
if c_a.int() == 1:
action_flag["action"] += 1
action_flag["action_frame"].append(count)
annotator_a.box_label(b_a, action_model.names[int(c_a)]+str(confidence_a),(255,0,0))
annotated_a_frame_coco = annotator_a.result()
@ -98,10 +98,11 @@ def analysis_video(source_path,output_path,people_modle_path,face_modle_path,act
cap.release()
output_movie.release()
# 计算巡检时长
diff = round((XJ_dict["tail"]-XJ_dict["head"])/fps,2)
fina_frame = [round(_ /fps,2) for _ in face_flag["frame"]]
s = ', '.join(map(str, fina_frame))
# 拉门时间
action_frame = [round(_ /fps,2) for _ in action_flag["action_frame"]]
s_action = ', '.join(map(str, action_frame))

Loading…
Cancel
Save