# 모델 불러오기 estimator = load_pretrain_model('VGG_origin') action_classifier = load_action_premodel('Action/taekwondo_recognition.h5') # 매개변수 초기화 realtime_fps = '0.0000' start_time = time.time() fps_interval = 1 fps_count = 0 run_timer = 0 frame_count = 0 # video file 읽기 및 쓰기 cap = choose_run_mode(args) video_writer = set_video_writer(cap, write_fps=int(7.0)) # skeleton data for Training을 txt 파일로 저장 # f = open('data\\txt_data\\taekwondoskill2-3-1.txt', 'a+') while cv.waitKey(1) < 0: has_frame, show = cap.read() if has_frame: fps_count += 1 frame_count += 1 # pose estimation humans = estimator.inference(show) # get pose info pose = TfPoseVisualizer.draw_pose_rgb( show, humans) # return frame, joints, bboxes, xcenter
cam_video = 1 #cam_video=0->camera cam_video=1->video file_p = "camera_record/*.mp4" #要读取的视频所在文件夹的路径 is_save = False vid_index = 0 #读取视频列表 if (cam_video == 1): video_list = glob.glob(file_p) video_len = len(video_list) print(video_list) if (video_len <= 0): print('No video in that file') sys.exit(1) cap = choose_run_mode(cam_video, video_list, vid_index) #读取视频 #video_writer = set_video_writer(cap, write_fps=int(7.0)) video_writer = set_video_writer(cap, write_fps=int(30.0), output_path='after_cam.mp4') video_writer_origin = set_video_writer(cap, write_fps=int(30.0), output_path='origin_cam.mp4') vid_index += 1 if is_save: f = open('origin_data.txt', 'a+') cur_pose = {} befo_pose = {} cur_box = {} cur_tag = {} delay_rec = {} detect_thresh = 5 is_suspicious = False
'mobilenet_thin') #返回一个类的句柄TfPoseVisualizer 并且建立了计算图 # action_classifier = load_action_premodel('Action/Es_all_demo.h5') #返回动作分类模型 且里面定义了tracker action_classifier = load_action_premodel( 'Action/framewise_recognition_bobei.h5') #返回动作分类模型 且里面定义了tracker # 参数初始化 realtime_fps = '0.0000' start_time = time.time() fps_interval = 1 fps_count = 0 run_timer = 0 frame_count = 0 #读写视频文件(仅测试过webcam输入) cap = choose_run_mode(args) #选择摄像头或者是本地文件 video_writer = set_video_writer(cap, write_fps=int(12)) #保存到本地的视频用到的参数初始化 video_1 = cv.VideoWriter('test_out/alpha.mp4', cv.VideoWriter_fourcc(*'mp4v'), int(12), (round(cap.get(cv.CAP_PROP_FRAME_WIDTH)), round(cap.get(cv.CAP_PROP_FRAME_HEIGHT)))) # # 保存关节数据的txt文件,用于训练过程(for training) # f = open('origin_data.txt', 'a+') #通过openPose提取keyPoint 然后标记keyPoint进行分类训练 最后通过openpose送到分类 while True and cap.isOpened(): #loop has_frame, show = cap.read() #framewise if has_frame: fps_count += 1 frame_count += 1 #crop image ,then ,the image into network #todo 缩小检测范围 显然影响到了检测精度 想要改变显示显然需要从节点生成后去做了 # pose estimation body_parts PartPair uidx_list humans = estimator.inference(show) #返回heatMat pafMat空间地址
file_p = "camera_record/*.mp4" #要读取的视频所在文件夹的路径 is_save = True vid_index = 0 #读取视频列表 if (cam_video == 1): video_list = glob.glob(file_p) video_len = len(video_list) print(video_list) if (video_len <= 0): print('No video in that file') sys.exit(1) cap = choose_run_mode(cam_video, video_list, vid_index) #读取视频 #存储处理后的视频 tmp_string = 'after_process_' + str(vid_index) + '.mp4' video_writer = set_video_writer(cap, write_fps=int(30.0), output_path=tmp_string) #存储获取的关节点信息 目前只考虑单人的情况 if is_save: data_file = 'gained_data/origin_data_' + str(vid_index) + '.txt' f = open(data_file, 'a+') vid_index += 1 while cv.waitKey(1) < 0: #while True : has_frame, show = cap.read() if has_frame: fps_count += 1 frame_count += 1 # pose estimation humans = estimator.inference(show) #openpose输出检测到的humans(人体关键点) # get pose info