Safemotion Lib
Loading...
Searching...
No Matches
Variables
action_demo_with_video Namespace Reference

Variables

list sys_path = ['/workspace/smlab', '/workspace']
 
str det_cfg_path = '/workspace/smlab/smdetect/configs/yolo/yolov8.py'
 
str track_cfg_path = '/workspace/smlab/smtrack/configs/bytetrack/bytetrack_base.py'
 
str pose_cfg_path = '/workspace/smlab/smpose/configs/mmpose/hrnet_trt.py'
 
str action_cfg_path = '/workspace/InnoTest/models/posec3d_action.py'
 
str posture_cfg_path = '/workspace/InnoTest/models/posec3d_pose.py'
 
str device = 'cuda:0'
 
 det_model = smrunner.build_model(det_cfg_path)
 
 track_model = smrunner.build_model(track_cfg_path)
 
 pose_model = smrunner.build_model(pose_cfg_path)
 
 action_model = smrunner.build_model(action_cfg_path).to(device)
 
 posture_model = smrunner.build_model(posture_cfg_path).to(device)
 
int action_sample = 20
 
int pose_sample = 6
 
 labelmap = dict()
 
list cvt_lower_map = [0, 1, 2, 0, 4, 5, 0, 7, 8, 9, 0, 11]
 
list cvt_upper_map = [0, 0, 0, 3, 0, 0]
 
list cvt_pose_map = [0, 0, 0, 0, 4, 4, 6, 0]
 
list cvt_hand_map = [0, 0, 0, 3]
 
 action_vis_param
 
 vis_param
 
str video_folder = '/media/safemotion/HDD5/pjm_test/ai_park_test_video'
 
 _
 
 video_path_list
 
str save_folder = '/media/safemotion/HDD5/pjm_test/ai_park_test_fps20'
 
str tmp_save_folder = '/media/safemotion/HDD5/pjm_test/tmp_clip_images_fps20'
 
 video_name = video_path.split('/')[-1]
 
 save_video_path = os.path.join(save_folder, video_name)
 
 cap = cv2.VideoCapture(video_path)
 
 total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
 
 fps = cap.get(cv2.CAP_PROP_FPS)
 
int action_k = int(fps+0.5)*2
 
int pose_k = int(fps+0.5)//2
 
dict track_data = {}
 
int frame_id = 0
 
 ret
 
 image
 
 end
 
 img_shape = image.shape[:2]
 
 vis_img = image.copy()
 
 det_result = det_model.run_detector(image)
 
 track_result = track_model.run_tracker(det_result['det_bboxes'], det_result['det_labels'], frame_id)
 
 pose_result = pose_model.run_detector(image, track_result['track_bboxes'][0])
 
 track_id = int(pose['track_id'])
 
list delete_list = []
 
int txt_pos_y = 50
 
 bbox = pose_q[-1]['bbox']
 
 last_frame = pose_q[-1]['frame_id']
 
str label = f'{track_id:3d}'
 
 action_result = action_model.run_recognizer(pose_q, action_k, action_sample, device=device)
 
 posture_result = posture_model.run_recognizer(pose_q[-pose_k:], pose_k, pose_sample, False, device=device)
 
list pose_label = cvt_pose_map[posture_result['pred_pose']]
 
list upper_label = cvt_upper_map[action_result['pred_action_upper']]
 
list lower_label = cvt_lower_map[action_result['pred_action_lower']]
 
list hand_label = cvt_hand_map[posture_result['pred_hand']]
 
str name = f'{frame_id:09d}.jpg'
 
 save_path = os.path.join(tmp_save_folder, name)
 
 half
 

Variable Documentation

◆ _

action_demo_with_video._
protected

Definition at line 76 of file action_demo_with_video.py.

◆ action_cfg_path

str action_demo_with_video.action_cfg_path = '/workspace/InnoTest/models/posec3d_action.py'

Definition at line 24 of file action_demo_with_video.py.

◆ action_k

int action_demo_with_video.action_k = int(fps+0.5)*2

Definition at line 110 of file action_demo_with_video.py.

◆ action_model

action_demo_with_video.action_model = smrunner.build_model(action_cfg_path).to(device)

Definition at line 32 of file action_demo_with_video.py.

◆ action_result

action_demo_with_video.action_result = action_model.run_recognizer(pose_q, action_k, action_sample, device=device)

Definition at line 172 of file action_demo_with_video.py.

◆ action_sample

int action_demo_with_video.action_sample = 20

Definition at line 39 of file action_demo_with_video.py.

◆ action_vis_param

action_demo_with_video.action_vis_param
Initial value:
1= dict(
2 box_color = (0, 255, 0),
3 box_thk = 3,
4 txt_color = (255, 255, 255),
5 txt_thk=3,
6 txt_scale=1.5,
7 box_type='xyxy'
8)

Definition at line 56 of file action_demo_with_video.py.

◆ bbox

action_demo_with_video.bbox = pose_q[-1]['bbox']

Definition at line 153 of file action_demo_with_video.py.

◆ cap

action_demo_with_video.cap = cv2.VideoCapture(video_path)

Definition at line 98 of file action_demo_with_video.py.

◆ cvt_hand_map

list action_demo_with_video.cvt_hand_map = [0, 0, 0, 3]

Definition at line 53 of file action_demo_with_video.py.

◆ cvt_lower_map

list action_demo_with_video.cvt_lower_map = [0, 1, 2, 0, 4, 5, 0, 7, 8, 9, 0, 11]

Definition at line 50 of file action_demo_with_video.py.

◆ cvt_pose_map

list action_demo_with_video.cvt_pose_map = [0, 0, 0, 0, 4, 4, 6, 0]

Definition at line 52 of file action_demo_with_video.py.

◆ cvt_upper_map

list action_demo_with_video.cvt_upper_map = [0, 0, 0, 3, 0, 0]

Definition at line 51 of file action_demo_with_video.py.

◆ delete_list

list action_demo_with_video.delete_list = []

Definition at line 149 of file action_demo_with_video.py.

◆ det_cfg_path

str action_demo_with_video.det_cfg_path = '/workspace/smlab/smdetect/configs/yolo/yolov8.py'

Definition at line 21 of file action_demo_with_video.py.

◆ det_model

action_demo_with_video.det_model = smrunner.build_model(det_cfg_path)

Definition at line 29 of file action_demo_with_video.py.

◆ det_result

action_demo_with_video.det_result = det_model.run_detector(image)

Definition at line 134 of file action_demo_with_video.py.

◆ device

str action_demo_with_video.device = 'cuda:0'

Definition at line 28 of file action_demo_with_video.py.

◆ end

action_demo_with_video.end

Definition at line 127 of file action_demo_with_video.py.

◆ fps

action_demo_with_video.fps = cap.get(cv2.CAP_PROP_FPS)

Definition at line 106 of file action_demo_with_video.py.

◆ frame_id

int action_demo_with_video.frame_id = 0

Definition at line 115 of file action_demo_with_video.py.

◆ half

action_demo_with_video.half

Definition at line 221 of file action_demo_with_video.py.

◆ hand_label

list action_demo_with_video.hand_label = cvt_hand_map[posture_result['pred_hand']]

Definition at line 190 of file action_demo_with_video.py.

◆ image

action_demo_with_video.image

Definition at line 119 of file action_demo_with_video.py.

◆ img_shape

action_demo_with_video.img_shape = image.shape[:2]

Definition at line 128 of file action_demo_with_video.py.

◆ label

str action_demo_with_video.label = f'{track_id:3d}'

Definition at line 157 of file action_demo_with_video.py.

◆ labelmap

action_demo_with_video.labelmap = dict()

Definition at line 43 of file action_demo_with_video.py.

◆ last_frame

action_demo_with_video.last_frame = pose_q[-1]['frame_id']

Definition at line 155 of file action_demo_with_video.py.

◆ lower_label

list action_demo_with_video.lower_label = cvt_lower_map[action_result['pred_action_lower']]

Definition at line 189 of file action_demo_with_video.py.

◆ name

str action_demo_with_video.name = f'{frame_id:09d}.jpg'

Definition at line 216 of file action_demo_with_video.py.

◆ pose_cfg_path

str action_demo_with_video.pose_cfg_path = '/workspace/smlab/smpose/configs/mmpose/hrnet_trt.py'

Definition at line 23 of file action_demo_with_video.py.

◆ pose_k

int action_demo_with_video.pose_k = int(fps+0.5)//2

Definition at line 111 of file action_demo_with_video.py.

◆ pose_label

list action_demo_with_video.pose_label = cvt_pose_map[posture_result['pred_pose']]

Definition at line 187 of file action_demo_with_video.py.

◆ pose_model

action_demo_with_video.pose_model = smrunner.build_model(pose_cfg_path)

Definition at line 31 of file action_demo_with_video.py.

◆ pose_result

action_demo_with_video.pose_result = pose_model.run_detector(image, track_result['track_bboxes'][0])

Definition at line 136 of file action_demo_with_video.py.

◆ pose_sample

int action_demo_with_video.pose_sample = 6

Definition at line 40 of file action_demo_with_video.py.

◆ posture_cfg_path

str action_demo_with_video.posture_cfg_path = '/workspace/InnoTest/models/posec3d_pose.py'

Definition at line 25 of file action_demo_with_video.py.

◆ posture_model

action_demo_with_video.posture_model = smrunner.build_model(posture_cfg_path).to(device)

Definition at line 33 of file action_demo_with_video.py.

◆ posture_result

action_demo_with_video.posture_result = posture_model.run_recognizer(pose_q[-pose_k:], pose_k, pose_sample, False, device=device)

Definition at line 179 of file action_demo_with_video.py.

◆ ret

action_demo_with_video.ret

Definition at line 119 of file action_demo_with_video.py.

◆ save_folder

str action_demo_with_video.save_folder = '/media/safemotion/HDD5/pjm_test/ai_park_test_fps20'

Definition at line 79 of file action_demo_with_video.py.

◆ save_path

action_demo_with_video.save_path = os.path.join(tmp_save_folder, name)

Definition at line 217 of file action_demo_with_video.py.

◆ save_video_path

action_demo_with_video.save_video_path = os.path.join(save_folder, video_name)

Definition at line 95 of file action_demo_with_video.py.

◆ sys_path

list action_demo_with_video.sys_path = ['/workspace/smlab', '/workspace']

Definition at line 3 of file action_demo_with_video.py.

◆ tmp_save_folder

action_demo_with_video.tmp_save_folder = '/media/safemotion/HDD5/pjm_test/tmp_clip_images_fps20'

Definition at line 83 of file action_demo_with_video.py.

◆ total_frames

action_demo_with_video.total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))

Definition at line 105 of file action_demo_with_video.py.

◆ track_cfg_path

str action_demo_with_video.track_cfg_path = '/workspace/smlab/smtrack/configs/bytetrack/bytetrack_base.py'

Definition at line 22 of file action_demo_with_video.py.

◆ track_data

dict action_demo_with_video.track_data = {}

Definition at line 114 of file action_demo_with_video.py.

◆ track_id

action_demo_with_video.track_id = int(pose['track_id'])

Definition at line 140 of file action_demo_with_video.py.

◆ track_model

action_demo_with_video.track_model = smrunner.build_model(track_cfg_path)

Definition at line 30 of file action_demo_with_video.py.

◆ track_result

action_demo_with_video.track_result = track_model.run_tracker(det_result['det_bboxes'], det_result['det_labels'], frame_id)

Definition at line 135 of file action_demo_with_video.py.

◆ txt_pos_y

int action_demo_with_video.txt_pos_y = 50

Definition at line 150 of file action_demo_with_video.py.

◆ upper_label

list action_demo_with_video.upper_label = cvt_upper_map[action_result['pred_action_upper']]

Definition at line 188 of file action_demo_with_video.py.

◆ video_folder

str action_demo_with_video.video_folder = '/media/safemotion/HDD5/pjm_test/ai_park_test_video'

Definition at line 75 of file action_demo_with_video.py.

◆ video_name

action_demo_with_video.video_name = video_path.split('/')[-1]

Definition at line 94 of file action_demo_with_video.py.

◆ video_path_list

action_demo_with_video.video_path_list

Definition at line 76 of file action_demo_with_video.py.

◆ vis_img

action_demo_with_video.vis_img = image.copy()

Definition at line 131 of file action_demo_with_video.py.

◆ vis_param

action_demo_with_video.vis_param
Initial value:
1= dict(
2 box_color = (0, 255, 0),
3 box_thk = 3,
4 txt_color = (255, 255, 255),
5 txt_thk=3,
6 txt_scale=1.5,
7 box_type='xyxy'
8)

Definition at line 65 of file action_demo_with_video.py.