62 lines
1.8 KiB
Python
62 lines
1.8 KiB
Python
|
|
import pathlib
|
|
from pathlib2 import Path
|
|
import os
|
|
import json
|
|
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")
|
|
path_data = Path("/mfs/lsen/DATA/Actor6/bg/processing2_0810")
|
|
|
|
# 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):
|
|
|
|
if not ipath_data.is_dir(): continue
|
|
iname = ipath_data.stem
|
|
print("processing {}/{} -> {} ... ".format(i, len(vpath_videos), ipath_data))
|
|
|
|
ipath_infor = ipath_data.joinpath("video/info.json")
|
|
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)
|
|
|
|
# check openpose
|
|
with open(str(ipath_infor), "r") as f:
|
|
info = json.load(f)
|
|
nframe_info = info['nframes']
|
|
|
|
# check frames
|
|
nframe_real = len(list(ipath_json.glob("*.json")))
|
|
if nframe_real == nframe_info:
|
|
print("\n Skip: have already done!")
|
|
continue
|
|
|
|
cmd = "CUDA_VISIBLE_DEVICES=8 \
|
|
./build/examples/openpose/openpose.bin \
|
|
--image_dir {} \
|
|
--write_video {} \
|
|
--write_keypoint_json {} \
|
|
--no_display \
|
|
--face \
|
|
--hand \
|
|
".format(str(ipath_frame), str(ipath_vis), str(ipath_json))
|
|
|
|
print("cmd = {}".format(cmd))
|
|
os.system(cmd)
|