Esempio n. 1
0
def generate_all_video(type, only_pose=False):
    assert type in video_types
    image_folder_base = "/media/jion/D/chenhaoming/DataSet/DouYin/images/{}".format(
        type)
    openpose_dir_base = "/media/jion/D/chenhaoming/DataSet/DouYin/machine_openpose/{}".format(
        type)
    output_dir_base = "/media/jion/D/chenhaoming/DataSet/DouYin/images/{}".format(
        type)

    images_folder_paths = utils_io_folder.get_immediate_subfolder_paths(
        image_folder_base)
    for image_folder_path in images_folder_paths:
        images_paths = utils_io_folder.get_immediate_childfile_paths(
            image_folder_path, exclude=".json")
        video_name = utils_io_folder.get_file_name_without_ext_from_path(
            image_folder_path)

        if not video_name.isdigit():
            continue

        input_jsons = utils_io_folder.get_immediate_childfile_paths(
            os.path.join(openpose_dir_base, video_name), ext=".json")
        output_dir = os.path.join(output_dir_base, video_name)
        assert len(images_paths) == len(input_jsons)
        print("images_path:{}".format(image_folder_path))
        for index in range(len(images_paths)):
            if only_pose:
                output_dir_final = os.path.join(output_dir, "only_pose")
            else:
                output_dir_final = os.path.join(output_dir, "pose_and_hand")
            openpose_convert_labelme_format(input_jsons[index],
                                            images_paths[index],
                                            output_dir_final,
                                            only_pose=only_pose)
Esempio n. 2
0
def generate_one_video(video_id, type=None):
    args.images_path = "F:/DataSet/douyin/images/dance/{0:06d}".format(
        video_id)
    args.output_dir = "F:/DataSet/douyin/trial/dance/{0:06d}".format(video_id)
    args.openpose_dir = "F:/DataSet/douyin/openpose/dance/{0:06d}".format(
        video_id)
    images_paths = utils_io_folder.get_immediate_childfile_paths(
        args.images_path, exclude=".json")
    input_jsons = utils_io_folder.get_immediate_childfile_paths(os.path.join(
        args.openpose_dir),
                                                                ext=".json")
    assert len(images_paths) == len(input_jsons)
    print("args.images_path:{}".format(args.images_path))
    for index in range(len(images_paths)):
        openpose_convert_labelme_format(input_jsons[index],
                                        images_paths[index], args.output_dir)
def start_tmp():
    labelme_base_path = "E:/temp/anno/{}"
    output_base_path = "E:/temp/anno/output/{}"
    temp_video_types = ["test", "train"]
    for video_type in temp_video_types:
        openpose_json_folder_type = output_base_path.format(video_type)
        labelme_folder = labelme_base_path.format(video_type)

        folder_name = utils_io_folder.get_file_name_without_ext_from_path(labelme_folder)

        openpose_json_folder = os.path.join(openpose_json_folder_type, folder_name)
        utils_io_folder.create_folder(openpose_json_folder)
        labelme_json_paths = utils_io_folder.get_immediate_childfile_paths(labelme_folder, ext="json")
        for labelme_json_path in tqdm(labelme_json_paths):
            # convert json one by one
            labelme_to_openpose(labelme_json_path, openpose_json_folder)
Esempio n. 4
0
def start_convert():
    labelme_base_path = "F:/DataSet/douyin/my_works/{}"
    index = ["000003"]
    for i in tqdm(index):
        path = labelme_base_path.format(i)
        print(path)
        labelme_json_paths = utils_io_folder.get_immediate_childfile_paths(
            path, ext="json")
        # TODO  之后要改成在统一的一个目录下
        output_folder = "F:/DataSet/douyin/my_works/{}".format(i)
        utils_io_folder.create_folder(output_folder)
        for labelme_json_path in tqdm(labelme_json_paths):
            number = int(
                utils_io_folder.get_file_name_without_ext_from_path(
                    labelme_json_path))
            labelme_to_openpose(labelme_json_path, output_folder)
Esempio n. 5
0
def work():
    root_path = "/media/jion/D/chenhaoming/DataSet/PoseTrack2017/cropped_image"
    first_paths = utils_io_folder.get_immediate_subfolder_paths(root_path)
    for first_path in first_paths:
        second_paths = utils_io_folder.get_immediate_subfolder_paths(
            first_path)
        for second_path in second_paths:
            image_paths = utils_io_folder.get_immediate_childfile_paths(
                second_path)
            if image_paths is None or len(image_paths) == 0:
                os.rmdir(second_path)
            else:
                pa = "/media/jion/D/chenhaoming/experiment/hmr"
                print(pa + second_path[61:])
                # new_path=""
                utils_io_folder.create_folder(pa + second_path[61:])
def start_convert():
    labelme_base_path = "F:/DataSet/DouYin/annotation_labelme_image/{}"
    output_base_path = "F:/DataSet/DouYin/annotation_openpose/{}"
    for video_type in tqdm(video_types):
        openpose_json_folder_type = output_base_path.format(video_type)
        labelme_folder = labelme_base_path.format(video_type)

        video_folder_sequence = utils_io_folder.get_immediate_subfolder_paths(labelme_folder)
        for video_folder in tqdm(video_folder_sequence):
            folder_name = utils_io_folder.get_file_name_without_ext_from_path(video_folder)
            if folder_name.isdigit():
                openpose_json_folder = os.path.join(openpose_json_folder_type, folder_name)
                utils_io_folder.create_folder(openpose_json_folder)
                labelme_json_paths = utils_io_folder.get_immediate_childfile_paths(video_folder, ext="json")
                for labelme_json_path in tqdm(labelme_json_paths):
                    # convert json one by one
                    labelme_to_openpose(labelme_json_path, openpose_json_folder)
Esempio n. 7
0
def work():
    cmd = "mv {} {}"
    root_path = "/media/jion/D/chenhaoming/DataSet/PoseTrack2017/posetrack_data/images"
    change_path = "/media/jion/D/chenhaoming/DataSet/PoseTrack2017/cropped_image/{}/{}"
    folder_paths = utils_io_folder.get_immediate_subfolder_paths(root_path)
    for folder_path in tqdm(folder_paths):
        first_folder_name = utils_io_folder.get_file_name_without_ext_from_path(folder_path)
        # print(first_folder_name)
        paths = utils_io_folder.get_immediate_subfolder_paths(folder_path)
        for path in paths:
            second_folder_name = utils_io_folder.get_file_name_without_ext_from_path(path)
            # print(second_folder_name)
            images_path = utils_io_folder.get_immediate_childfile_paths(path)
            new_path = change_path.format(first_folder_name, second_folder_name)
            utils_io_folder.create_folder(new_path)
            for image_path in images_path:
                image_name = utils_io_folder.get_file_name_without_ext_from_path(image_path)
                if image_name.find("transform") >= 0:
                    cmd_i = cmd.format(image_path, os.path.join(new_path, image_name))
                    os.system(cmd_i)
Esempio n. 8
0
def start(path):
    file_paths = utils_io_folder.get_immediate_childfile_paths(path)
    mota_paths = []
    for file_path in file_paths:
        file_name = utils_io_folder.get_file_name_without_ext_from_path(file_path)
        if file_name.find("MOT") > 0:
            mota_paths.append(file_path)

    wbk = xlwt.Workbook()
    sheet = wbk.add_sheet("sheet 1")
    sheet.write(0, 0, " ")
    i = 1
    for type in types:
        for name in names:
            sheet.write(i, 0, "{}-{}".format(type, name))
            i += 1
        sheet.write(i, 0, "")
        i += 1
    j = 1
    for file_path in mota_paths:
        file_name = utils_io_folder.get_file_name_without_ext_from_path(file_path)
        if file_name != total_name:
            index = file_name.find("_mpii")
            video_number = file_name[0:int(index)]
        else:
            video_number = "total"
        sheet.write(0, j, video_number)
        json_data = utils_json.read_json_from_file(file_path)
        i = 1
        for type in types:
            type_json_data = json_data[type]
            for index, _ in enumerate(names):
                sheet.write(i, j, type_json_data[index])
                i += 1
            sheet.write(i, j, "")
            i += 1
        j += 1

    interval_index = path.rindex("/")
    source_index = path.rindex("/", 0, interval_index)
    wbk.save("{}_{}.xls".format(path[source_index + 1:interval_index], path[interval_index + 1:]))
            labelme_object.shapes.append(point_shape(track_id, hand_keypoints_order[index].format("right_"), keypoint))
    if output_dir is None:
        # 输出 默认在input_json的路径下创建labelme文件夹。
        output_dir = os.path.join(utils_io_folder.get_parent_folder_from_path(input_json))
        # utils_io_folder.create_folder(output_dir)
        output_path = os.path.join(output_dir, utils_io_folder.replace_file_ext(image_name, "json"))
    else:
        utils_io_folder.create_folder(output_dir)
        output_path = os.path.join(output_dir, utils_io_folder.replace_file_ext(image_name, "json"))
    utils_json.write_json_to_file(labelme_object.to_dict(), output_path)


if __name__ == '__main__':
    args = parseArgs()
    print(args)
    test = True
    if test:
        args.images_path = "/media/jion/D/chenhaoming/DataSet/DouYin/images/dance/_a_1"
        args.output_dir = "/media/jion/D/chenhaoming/DataSet/DouYin/images/dance/_a_1"
    images_paths = utils_io_folder.get_immediate_childfile_paths(args.images_path, exclude=".json")
    intput_jsons = utils_io_folder.get_immediate_childfile_paths(os.path.join(args.images_path, "openpose"),
                                                                 ext=".json")
    assert len(images_paths) == len(intput_jsons)
    for index in tqdm(range(len(images_paths))):
        openpose_convert_labelme_format(intput_jsons[index], images_paths[index], args.output_dir)
    # print(images_paths)
    # print(intpus_jsons)
    # input_jsons = ""
    # input_image_path
    # openpose_convert_labelme_format(args.input_json, args.input_images_dir, args.output_dir)
Esempio n. 10
0
#!/usr/bin/python
# -*- coding:utf8 -*-
"""
    Author: Haoming Chen
    E-mail: [email protected]
    Time: 2020/04/13
    Description:
"""
import os, sys

sys.path.append(os.path.abspath("../common"))
from common import utils_image, utils_io_folder
from tqdm import tqdm

if __name__ == '__main__':
    image_folder_base = "/media/jion/D/chenhaoming/DataSet/DouYin/images/hyj/{}"
    outvid_path_base = "/media/jion/D/chenhaoming/DataSet/DouYin/videos/hyj/{}.mp4"
    list = ["000001", "000002"]
    for item in tqdm(list):
        image_folder = image_folder_base.format(item)
        outvid_path = outvid_path_base.format(item)
        images_paths = utils_io_folder.get_immediate_childfile_paths(
            image_folder, ext="jpg")
        utils_image.make_video_from_images(images_paths, outvid_path)
Esempio n. 11
0
# -*- coding:utf8 -*-
"""
    Author: Haoming Chen
    E-mail: [email protected]
    Time: 2020/05/29
    Description:
"""
from common import utils_io_folder
import shutil
from tqdm import tqdm

train_base_path = "/media/jion/D/chenhaoming/experiment/tubes/384x288/train"

train_subfolder_paths = utils_io_folder.get_immediate_subfolder_paths(train_base_path)

for train_subfolder_path in tqdm(train_subfolder_paths):
    video_paths = utils_io_folder.get_immediate_subfolder_paths(train_subfolder_path)
    for video_path in tqdm(video_paths):
        video_npy_path = utils_io_folder.get_immediate_childfile_paths(video_path)
        shutil.copy(video_npy_path[0], "/media/jion/D/chenhaoming/experiment/tubes/384x288/npy/train/")

val_base_path = "/media/jion/D/chenhaoming/experiment/tubes/384x288/val"

val_subfolder_paths = utils_io_folder.get_immediate_subfolder_paths(val_base_path)

for val_subfolder_path in tqdm(val_subfolder_paths):
    video_paths = utils_io_folder.get_immediate_subfolder_paths(val_subfolder_path)
    for video_path in tqdm(video_paths):
        video_npy_path = utils_io_folder.get_immediate_childfile_paths(video_path)
        shutil.copy(video_npy_path[0], "/media/jion/D/chenhaoming/experiment/tubes/384x288/npy/val/")
Esempio n. 12
0
            utils_io_folder.create_folder(output_dir)
            output_path = os.path.join(
                output_dir,
                utils_io_folder.replace_file_ext(image_name, "json"))
            utils_json.write_json_to_file(labelme_object.to_dict(),
                                          output_path)


if __name__ == '__main__':
    args = parseArgs()
    test = True
    if test:
        args.input_json = "/media/jion/D/chenhaoming/DataSet/PoseTrack2017/val_json/source/000342_mpii.json"
        args.images_path_base = "/media/jion/D/chenhaoming/DataSet/PoseTrack2017/posetrack_data"
        args.output_dir_base = "/media/jion/D/chenhaoming/DataSet/PoseTrack2017/val_json/labelme"
        posetrack2017_convert_labelme_format(args.input_json,
                                             args.images_path_base,
                                             args.output_dir_base)
    else:
        # images_paths = utils_io_folder.get_immediate_childfile_paths(args.images_path, exclude=".json")
        intput_jsons = utils_io_folder.get_immediate_childfile_paths(
            os.path.join(args.input_json), ext=".json")
        # assert len(images_paths) == len(intput_jsons)
        # for index in tqdm(range(len(intput_jsons))):
        #     posetrack2017_convert_labelme_format(intput_jsons[index], images_paths[index], args.output_dir)
        # print(images_paths)
        # print(intpus_jsons)
        # input_jsons = ""
        # input_image_path
        # openpose_convert_labelme_format(args.input_json, args.input_images_dir, args.output_dir)