Files
audio2motion/scripts/BG_Actor6/run-02-prepare-data-bg-pose-openpose.py
T
2022-06-24 15:35:59 +08:00

48 lines
1.2 KiB
Python

from pathlib2 import Path
import os
import os, sys
sys.path.insert(0, os.getcwd())
import __future__
import sys
if __name__ == "__main__":
path_data = Path("/mfs/lsen/DATA/Actor6/bg/processing")
# get all videos
vpath_videos = sorted(path_data.glob("*"), reverse=False)
print("Have", len(vpath_videos), " dir files")
# for each video
for i, ipath_data in enumerate(vpath_videos):
iname = ipath_data.stem
print("processing {}/{} -> {} ... ".format(i, len(vpath_videos), ipath_data))
ipath_frame = ipath_data.joinpath("frames")
ipath_json = ipath_data.joinpath("openpose")
ipath_json.mkdir(parents=True, exist_ok=True)
ipath_vis = ipath_data.joinpath("video", "openpose_vis.avi")
ipath_vis.parent.mkdir(parents=True, exist_ok=True)
cmd = "CUDA_VISIBLE_DEVICES=7 \
./build/examples/openpose/openpose.bin \
--image_dir {} \
--write_video {} \
--write_keypoint_json {} \
--no_display \
--face \
".format(str(ipath_frame), str(ipath_vis), str(ipath_json))
print("cmd = {}".format(cmd))
os.system(cmd)