|
|
|
@ -110,7 +110,6 @@ class DealVideo():
|
|
|
|
|
print(video_path,"Ignoring empty camera frame.")
|
|
|
|
|
# print('video_fps:',video_fps,'count_fps:',count_fps)
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# print('count_fps_read_video=',count_fps)
|
|
|
|
|
imgsize = frame.shape
|
|
|
|
@ -138,17 +137,17 @@ class DealVideo():
|
|
|
|
|
if person_list:
|
|
|
|
|
|
|
|
|
|
count_fps_del_re,updata_result_contact = self.analysis_by_bbox(imgsize=imgsize,
|
|
|
|
|
detect_result=person_list,
|
|
|
|
|
dertpara=10,
|
|
|
|
|
start_fps=start_fps,
|
|
|
|
|
now_fps=count_fps,
|
|
|
|
|
label_name='person',
|
|
|
|
|
video_path=video_path,
|
|
|
|
|
frame_result_contact=frame_result_contact,
|
|
|
|
|
parameter_fps=50,
|
|
|
|
|
count_fps_del=count_fps_del,
|
|
|
|
|
video_end=video_end
|
|
|
|
|
)
|
|
|
|
|
detect_result=person_list,
|
|
|
|
|
dertpara=4,
|
|
|
|
|
start_fps=start_fps,
|
|
|
|
|
now_fps=count_fps,
|
|
|
|
|
label_name='person',
|
|
|
|
|
video_path=video_path,
|
|
|
|
|
frame_result_contact=frame_result_contact,
|
|
|
|
|
parameter_fps=150,
|
|
|
|
|
count_fps_del=count_fps_del,
|
|
|
|
|
video_end=video_end
|
|
|
|
|
)
|
|
|
|
|
count_fps_del = count_fps_del_re
|
|
|
|
|
frame_result_contact = updata_result_contact
|
|
|
|
|
|
|
|
|
@ -220,18 +219,21 @@ class DealVideo():
|
|
|
|
|
start_fps = head_result_contact[0]['fps']
|
|
|
|
|
else:
|
|
|
|
|
start_fps = count_fps
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
count_fps_del_re,updata_result_contact = self.analysis_by_bbox(imgsize=imgsize,
|
|
|
|
|
detect_result=head_result_1,
|
|
|
|
|
dertpara=1,
|
|
|
|
|
start_fps=start_fps,
|
|
|
|
|
now_fps=count_fps,
|
|
|
|
|
label_name='head',
|
|
|
|
|
video_path=video_path,
|
|
|
|
|
frame_result_contact=head_result_contact,
|
|
|
|
|
parameter_fps=25,
|
|
|
|
|
count_fps_del=count_fps_del_head,
|
|
|
|
|
video_end=video_end
|
|
|
|
|
)
|
|
|
|
|
detect_result=head_result_1,
|
|
|
|
|
dertpara=1,
|
|
|
|
|
start_fps=start_fps,
|
|
|
|
|
now_fps=count_fps,
|
|
|
|
|
label_name='head',
|
|
|
|
|
video_path=video_path,
|
|
|
|
|
frame_result_contact=head_result_contact,
|
|
|
|
|
parameter_fps=80,
|
|
|
|
|
count_fps_del=count_fps_del_head,
|
|
|
|
|
video_end=video_end
|
|
|
|
|
)
|
|
|
|
|
count_fps_del_head = count_fps_del_re
|
|
|
|
|
head_result_contact = updata_result_contact
|
|
|
|
|
|
|
|
|
@ -243,19 +245,21 @@ class DealVideo():
|
|
|
|
|
start_fps = count_fps
|
|
|
|
|
|
|
|
|
|
count_fps_del_re,updata_result_contact = self.analysis_by_bbox(imgsize=imgsize,
|
|
|
|
|
detect_result=hands_result_1,
|
|
|
|
|
dertpara=2,
|
|
|
|
|
start_fps=start_fps,
|
|
|
|
|
now_fps=count_fps,
|
|
|
|
|
label_name='hands',
|
|
|
|
|
video_path=video_path,
|
|
|
|
|
frame_result_contact=hands_result_contact,
|
|
|
|
|
parameter_fps=25,
|
|
|
|
|
count_fps_del=count_fps_del_hand,
|
|
|
|
|
video_end=video_end
|
|
|
|
|
)
|
|
|
|
|
detect_result=hands_result_1,
|
|
|
|
|
dertpara=2,
|
|
|
|
|
start_fps=start_fps,
|
|
|
|
|
now_fps=count_fps,
|
|
|
|
|
label_name='hands',
|
|
|
|
|
video_path=video_path,
|
|
|
|
|
frame_result_contact=hands_result_contact,
|
|
|
|
|
parameter_fps=80,
|
|
|
|
|
count_fps_del=count_fps_del_hand,
|
|
|
|
|
video_end=video_end
|
|
|
|
|
)
|
|
|
|
|
count_fps_del_hand = count_fps_del_re
|
|
|
|
|
hands_result_contact = updata_result_contact
|
|
|
|
|
# print(count_fps,'----------------hands_result_1-------------------------------',hands_result_1)
|
|
|
|
|
# print(count_fps,"-------------------------updata_result_contact----------------------:",updata_result_contact)
|
|
|
|
|
|
|
|
|
|
count_fps += 1
|
|
|
|
|
|
|
|
|
@ -276,17 +280,19 @@ class DealVideo():
|
|
|
|
|
batch_size=self.batch_size,
|
|
|
|
|
predictor=self.predictor,
|
|
|
|
|
InferenceHelper=self.infer)
|
|
|
|
|
|
|
|
|
|
if result_list['topk_scores'] > 0.9:
|
|
|
|
|
|
|
|
|
|
video_base_name = os.path.basename(video_path)
|
|
|
|
|
video_save_select_path = self.video_save_file + '/' + 'video_select_dect/'+ str(result_list['topk_class'])
|
|
|
|
|
os.makedirs(video_save_select_path, exist_ok=True)
|
|
|
|
|
video_save = os.path.join(video_save_select_path, video_base_name)
|
|
|
|
|
|
|
|
|
|
video_base_name = os.path.basename(video_path)
|
|
|
|
|
video_save_select_path = self.video_save_file + '/' + 'video_select_dect/'+ str(result_list['topk_class'])
|
|
|
|
|
os.makedirs(video_save_select_path, exist_ok=True)
|
|
|
|
|
video_save = os.path.join(video_save_select_path, video_base_name)
|
|
|
|
|
|
|
|
|
|
os.rename(video_path, video_save)
|
|
|
|
|
os.rename(video_path, video_save)
|
|
|
|
|
|
|
|
|
|
self.videoreturnQueue.put(video_save)
|
|
|
|
|
self.videoreturnQueue.put(video_save)
|
|
|
|
|
|
|
|
|
|
print("result_list_video_select_dect:",result_list)
|
|
|
|
|
print("result_list_video_select_dect:",result_list)
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print(e)
|
|
|
|
@ -295,7 +301,7 @@ class DealVideo():
|
|
|
|
|
'''
|
|
|
|
|
imgsize:图片的尺寸,
|
|
|
|
|
detect_result:检测到的图像的结果,bboxlist
|
|
|
|
|
dertpara:标注框修正参数,取整数,2,3
|
|
|
|
|
dertpara:scale_factor:缩放因子,大于 1 表示放大,小于 1 表示缩小
|
|
|
|
|
start_fps: 对比列表中的起始帧
|
|
|
|
|
now_fpsl:当前帧率
|
|
|
|
|
label_name:用于分析的检测类别
|
|
|
|
@ -306,9 +312,7 @@ class DealVideo():
|
|
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
bbox_list = tools_function.para_list_correction(images_size=imgsize,
|
|
|
|
|
bbox_list=detect_result,
|
|
|
|
|
dertpara=dertpara)
|
|
|
|
|
bbox_list = tools_function.para_list_correction(images_size=imgsize,bbox_list=detect_result,dertpara=dertpara)
|
|
|
|
|
|
|
|
|
|
count_fps_del_re,update_frame_result_contact = self.get_cut_message(fps1=now_fps,
|
|
|
|
|
label_name = label_name,
|
|
|
|
@ -354,20 +358,20 @@ class DealVideo():
|
|
|
|
|
|
|
|
|
|
# cut_dict = {'video_path':video_path,'label_name':label_name,"stop_fps":fps1,'bbox_list':example_lst}
|
|
|
|
|
|
|
|
|
|
# start_fps = example_lst[0]['fps']
|
|
|
|
|
start_fps = example_lst[0]['fps']
|
|
|
|
|
|
|
|
|
|
if count_fps_del <= 2:
|
|
|
|
|
if count_fps_del <= 5:
|
|
|
|
|
|
|
|
|
|
frame_result_contact = frame_result_contact
|
|
|
|
|
count_fps_del = count_fps_del + 1
|
|
|
|
|
|
|
|
|
|
# else:
|
|
|
|
|
|
|
|
|
|
# if (fps1 - start_fps) < 5:
|
|
|
|
|
if (fps1 - start_fps) < 15:
|
|
|
|
|
|
|
|
|
|
# frame_result_contact = frame_result_contact
|
|
|
|
|
else:
|
|
|
|
|
frame_result_contact = frame_result_contact
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
cut_dict = {'video_path':video_path,'label_name':label_name,"stop_fps":fps1,'bbox_list':example_lst}
|
|
|
|
|
frame_result_contact = [item for item in frame_result_contact if item not in example_lst]
|
|
|
|
|
self.cutbboxQueue.put(cut_dict)
|
|
|
|
@ -516,23 +520,29 @@ class DealVideo():
|
|
|
|
|
bbox_int_list = [int(bbox_list[0]),int(bbox_list[1]),int(bbox_list[2]),int(bbox_list[3])]
|
|
|
|
|
w = bbox_int_list[2] - bbox_int_list[0]
|
|
|
|
|
h = bbox_int_list[3] - bbox_int_list[1]
|
|
|
|
|
size = (w,h)
|
|
|
|
|
# 根据标签保存不同视频分类
|
|
|
|
|
# bbox_name = '{}-{}-{}_{}'.format(int(bbox_list[0]), int(bbox_list[1]), int(bbox_list[2]), int(bbox_list[3]))
|
|
|
|
|
video_name_save = '{}__{}-{}-{}_{}-{}-{}-{}.avi'.format(video_basename, start_fps, stop_fps, video_fps,int(bbox_list[0]), int(bbox_list[1]), int(bbox_list[2]), int(bbox_list[3]))
|
|
|
|
|
video_save_file = self.video_save_file + '/' + file_name
|
|
|
|
|
os.makedirs(video_save_file, exist_ok=True)
|
|
|
|
|
video_save_path = os.path.join(video_save_file, video_name_save)
|
|
|
|
|
videoWriter =cv2.VideoWriter(video_save_path,cv2.VideoWriter_fourcc('X','V','I','D'),fps,size)
|
|
|
|
|
|
|
|
|
|
tools_function.save_seg_video(video_name=video_path,
|
|
|
|
|
frameToStart=start_fps,
|
|
|
|
|
frametoStop=stop_fps,
|
|
|
|
|
videoWriter=videoWriter,
|
|
|
|
|
bbox=bbox_int_list,
|
|
|
|
|
size=size)
|
|
|
|
|
videoWriter.release()
|
|
|
|
|
self.videoQueue2.put(video_save_path)
|
|
|
|
|
size = [w,h]
|
|
|
|
|
if tools_function.determine_zero(size):
|
|
|
|
|
size = (w,h)
|
|
|
|
|
|
|
|
|
|
# 根据标签保存不同视频分类
|
|
|
|
|
# bbox_name = '{}-{}-{}_{}'.format(int(bbox_list[0]), int(bbox_list[1]), int(bbox_list[2]), int(bbox_list[3]))
|
|
|
|
|
video_name_save = '{}__{}-{}-{}_{}-{}-{}-{}.avi'.format(video_basename, start_fps, stop_fps, video_fps,int(bbox_list[0]), int(bbox_list[1]), int(bbox_list[2]), int(bbox_list[3]))
|
|
|
|
|
video_save_file = self.video_save_file + '/' + file_name
|
|
|
|
|
os.makedirs(video_save_file, exist_ok=True)
|
|
|
|
|
video_save_path = os.path.join(video_save_file, video_name_save)
|
|
|
|
|
videoWriter =cv2.VideoWriter(video_save_path,cv2.VideoWriter_fourcc('X','V','I','D'),fps,size)
|
|
|
|
|
|
|
|
|
|
tools_function.save_seg_video(video_name=video_path,
|
|
|
|
|
frameToStart=start_fps,
|
|
|
|
|
frametoStop=stop_fps,
|
|
|
|
|
videoWriter=videoWriter,
|
|
|
|
|
bbox=bbox_int_list,
|
|
|
|
|
size=size)
|
|
|
|
|
videoWriter.release()
|
|
|
|
|
self.videoQueue2.put(video_save_path)
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
print('-----------------agrag-----------------',size,'-----------------agag-----------------')
|
|
|
|
|
|
|
|
|
|
cap.release()
|
|
|
|
|
|
|
|
|
@ -560,8 +570,8 @@ class DealVideo():
|
|
|
|
|
|
|
|
|
|
self.videoQueue3.put(video_path)
|
|
|
|
|
|
|
|
|
|
if labels == 'head' or labels == 'hands':
|
|
|
|
|
|
|
|
|
|
# if labels == 'head' or labels == 'hands':
|
|
|
|
|
if labels == 'hands':
|
|
|
|
|
self.videodetQueue.put(video_path)
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
@ -581,7 +591,7 @@ class DealVideo():
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
t1 = time.time()
|
|
|
|
|
video = "test_video/test/0711ahgh.avi"
|
|
|
|
|
video = "E:/Bank_files/Bank_02/dataset/video_kf/02.mp4"
|
|
|
|
|
video_save = 'test_video'
|
|
|
|
|
|
|
|
|
|
# 初始化目标检测
|
|
|
|
@ -589,8 +599,8 @@ if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
# 初始化pptsmv2
|
|
|
|
|
config = 'model_file/inference/pptsm_lcnet_k400_16frames_uniform.yaml' # 配置文件地址
|
|
|
|
|
model_file = 'model_file/inference/ppTSMv2.pdmodel' # 推理模型存放地址
|
|
|
|
|
params_file = 'model_file/inference/ppTSMv2.pdiparams'
|
|
|
|
|
model_file = 'model_file/inference_hands_2/ppTSMv2.pdmodel' # 推理模型存放地址
|
|
|
|
|
params_file = 'model_file/inference_hands_2/ppTSMv2.pdiparams'
|
|
|
|
|
# batch_size= 1
|
|
|
|
|
infer,predictor = PP_TSMv2_predict().create_inference_model(config,model_file,params_file)
|
|
|
|
|
# PP_TSMv2_predict().predict(config,input_file,batch_size,predictor,infer)
|
|
|
|
|