Exemple #1
0
def setup_input(args):
    """
    Input type can be 
        an image file
        a video file
        a folder with image files
        a folder with bbox (json) files
        "webcam"
    
    """
    image_exts = ('jpg', 'png', 'jpeg', 'bmp')
    video_exts = ('mp4', 'avi', 'mov')

    # get type of input
    input_type = __get_input_type(args)

    if input_type == 'video':
        cap = cv2.VideoCapture(args.input_path)
        assert cap.isOpened(), f"Failed in opening video: {args.input_path}"
        __video_setup(args)
        return input_type, cap

    elif input_type == 'webcam':
        cap = cv2.VideoCapture(0)  #webcam input
        return input_type, cap

    elif input_type == 'image_dir':
        image_list = gnu.get_all_files(args.input_path, image_exts, "relative")
        image_list = [
            osp.join(args.input_path, image_name) for image_name in image_list
        ]
        __img_seq_setup(args)
        return input_type, image_list

    elif input_type == 'bbox_dir':
        __img_seq_setup(args)
        json_files = gnu.get_all_files(args.input_path, '.json', "relative")
        input_data = list()
        for json_file in json_files:
            json_path = osp.join(args.input_path, json_file)
            image_path, body_bbox_list, hand_bbox_list = load_info_from_json(
                json_path)
            input_data.append(
                dict(image_path=image_path,
                     hand_bbox_list=hand_bbox_list,
                     body_bbox_list=body_bbox_list))
        return input_type, input_data

    else:
        assert False, "Unknown input type"
Exemple #2
0
def main():
    args = DemoOptions().parse()

    # load pkl files
    pkl_files = gnu.get_all_files(args.pkl_dir, ".pkl", "full")

    # get smpl type
    demo_type, smpl_type = __get_data_type(pkl_files)

    # get smpl model
    smpl_model = __get_smpl_model(demo_type, smpl_type)

    # Set Visualizer
    assert args.renderer_type in ['pytorch3d', 'opendr'], \
        f"{args.renderer_type} not implemented yet."
    from renderer.screen_free_visualizer import Visualizer
    visualizer = Visualizer(args.renderer_type)

    # load smpl model
    visualize_prediction(args, demo_type, smpl_type, smpl_model, pkl_files,
                         visualizer)