def merge_posetrack_jsons():
    posetrack_annotation_folder = "../data/Data_2017/posetrack_data/annotations/train"
    save_json_path = "posetrack_merged_train.json"
    gt_json_paths = get_immediate_childfile_paths(posetrack_annotation_folder,
                                                  "json")
    merge_json(gt_json_paths, save_json_path)

    posetrack_annotation_folder = "../data/Data_2017/posetrack_data/annotations/val"
    save_json_path = "posetrack_merged_val.json"
    gt_json_paths = get_immediate_childfile_paths(posetrack_annotation_folder,
                                                  "json")
    merge_json(gt_json_paths, save_json_path)
    return
def test_track_all(dataset = "test"):
    image_dir = "/export/guanghan/Data_2018_lighttrack/posetrack_data/"
    visualize_folder = "/export/guanghan/Data_2018_lighttrack/posetrack_results/lighttrack/visualize/"
    output_video_folder = "/export/guanghan/cpn/data"
    track_json_folder = "/export/guanghan/Data_2018/posetrack_results/{}/track/jsons_submission3".format(dataset)
    video_name_list = ["018630_mpii_test", "024156_mpii_test"]#["022699_mpii_test", "023730_mpii_test", "014307_mpii_test", "014313_mpii_test", "015868_mpii_test"]

    for video_name in video_name_list:
        json_name = os.path.basename(video_name) + ".json"
        track_json = os.path.join(track_json_folder, json_name)
        print("visualization!")
        create_folder(visualize_folder)
        if dataset == "val":
            image_subfolder = os.path.join(image_dir, "images/val", os.path.basename(video_name))
        elif dataset == "test":
            image_subfolder = os.path.join(image_dir, "images/test", os.path.basename(video_name))
        print(image_subfolder)

        visualize_subfolder = os.path.join(visualize_folder, os.path.basename(video_name))
        create_folder(visualize_subfolder)
        show_all_from_standard_json(track_json, classes, joint_pairs, joint_names, image_subfolder, visualize_subfolder, flag_track = True)

        img_paths = get_immediate_childfile_paths(visualize_subfolder)
        visualize_video_path = os.path.join(visualize_folder, os.path.basename(video_name)+".mp4")
        make_video_from_images(img_paths, visualize_video_path, fps=15, size=None, is_color=True, format="xvid")
    return
def test_make_video_from_images():
    #img_folder_path = "/Users/guanghan.ning/Desktop/working/test_posetrack_visualize/"
    #output_video_path = "/Users/guanghan.ning/Desktop/working/video.mp4"

    #img_folder_path = "/Users/guanghan.ning/Desktop/working/visualize_douyin_3/track/"
    #output_video_path = "/Users/guanghan.ning/Desktop/working/visualize_douyin_3/video_fast.mp4"

    img_folder_path = "/Users/guanghan.ning/Desktop/working/exp4/pose/"
    output_video_path = "/Users/guanghan.ning/Desktop/working/exp4/video_fast.mp4"

    img_paths = get_immediate_childfile_paths(img_folder_path)
    make_video_from_images(img_paths, output_video_path, fps=20, size=None, is_color=True, format="XVID")
    print("Done!")
    return
Exemple #4
0
def test_make_video_from_images():
    '''
    img_folder_path = "/Users/guanghan.ning/Desktop/working/douyin_4/visualize/poly/"
    output_video_path = "/Users/guanghan.ning/Desktop/working/douyin_4/visualize/video_poly.mp4"
    '''
    img_folder_path = "/Users/guanghan.ning/Desktop/leftImg8bit_demoVideo/leftImg8bit/demoVideo/visualize/poly/"
    output_video_path = "/Users/guanghan.ning/Desktop/leftImg8bit_demoVideo/leftImg8bit/demoVideo/visualize/video_poly.mp4"

    img_paths = get_immediate_childfile_paths(img_folder_path)
    make_video_from_images(img_paths,
                           output_video_path,
                           fps=20,
                           size=None,
                           is_color=True,
                           format="XVID")
    print("Done!")
    return
Exemple #5
0
def get_file_paths_of_stepsize_in_numpy_folder(folder_path, frame_id, nsteps):
    file_paths = get_immediate_childfile_paths(folder_path)
    [st, ed] = get_range_of_stepsize_by_frame_id(nsteps, frame_id)
    file_paths_batch = file_paths[st:ed]
    return file_paths_batch
Exemple #6
0
def get_file_paths_of_stepsize_in_numpy_folder(folder_path, frame_id, nsteps):
    file_paths = get_immediate_childfile_paths(folder_path)
    [st, ed] = get_range_of_stepsize_by_frame_id(nsteps, frame_id)
    file_paths_batch = file_paths[st:ed]
    return file_paths_batch
Exemple #7
0
    width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))  # 获取宽度
    height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))  # 获取宽度
    i = 0
    while (isOpened):  # 当视频被打开了
        i = i + 1  # i++
        (flag, frame) = cap.read()  # 读取每一张 flag<读取是否成功> frame<内容>
        file_name = "{0:08d}.jpg".format(i)
        if outimages_path is not None:
            utils_io_folder.create_folder(outimages_path)
            file_path = os.path.join(outimages_path, file_name)
        else:
            utils_io_folder.create_folder("output")
            file_path = os.path.join("output", file_name)
        if flag:  # 读取成功的话
            # 写入文件,1 文件名 2 文件内容 3 质量设置
            cv2.imwrite(file_path, frame, [cv2.IMWRITE_JPEG_QUALITY, 100])


if __name__ == '__main__':
    # make_images_from_video(video_path="C:/Users/chenh/Desktop/compare/openpose_output/16662.avi",
    #                        outimages_path="C:/Users/chenh/Desktop/compare/openpose_output/decompose_images")
    img_paths = utils_io_folder.get_immediate_childfile_paths(
        "C:/Users/chenh/Desktop/compare/openpose_output/decompose_images/")

    make_video_from_images(
        img_paths=img_paths,
        outvid_path="C:/Users/chenh/Desktop/compare/openpose_output/test.avi")
    # img_path = ""
    # outvid_path = ""
    # make_video_from_images(img_paths=, outvid_path=)