-
Notifications
You must be signed in to change notification settings - Fork 123
/
run_pipeline.sh
59 lines (50 loc) · 1.92 KB
/
run_pipeline.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/bash
set -e
# input param
# $1: sequence name
# $2: whether the video is upper body only (false by default, enable by -f)
seqName=$1
upperBody=$2
# Assume that you already have a video in $dataDir/(seqName)/(seqName).mp4
dataDir=./data/
# Git clone openpose to ../openpose and compile with cmake
openposeDir=../openpose/
# convert to absolute path
MTCDir=$(readlink -f .)
dataDir=$(readlink -f $dataDir)
openposeDir=$(readlink -f $openposeDir)
if [ ! -f $dataDir/$seqName/calib.json ]; then
echo "Camera intrinsics not specified, use default."
cp -v POF/calib.json $dataDir/$seqName
fi
# use ffmpeg to extract image frames
cd $dataDir/$seqName
if [ ! -d raw_image ]; then
mkdir raw_image
ffmpeg -i $seqName.mp4 raw_image/${seqName}_%08d.png
fi
# run OpenPose on image frames
if [ ! -d openpose_result ]; then
mkdir openpose_result
cd $openposeDir
./build/examples/openpose/openpose.bin --face --hand --image_dir $dataDir/$seqName/raw_image --write_json $dataDir/$seqName/openpose_result --render_pose 0 --display 0 -model_pose BODY_25 --number_people_max 1
fi
# merge openpose results into a single file
cd $MTCDir
numFrame=$(ls $dataDir/$seqName/openpose_result/$seqName_* | wc -l)
python3 POF/collect_openpose.py -n $seqName -r $dataDir/$seqName -c $numFrame
# run POF generation code
cd POF
if [ ! -d $dataDir/$seqName/net_output/ ]; then
python3 save_total_sequence.py -s $seqName -p $dataDir/$seqName $upperBody
# python3 save_total_sequence.py -s $seqName -p $dataDir/$seqName --end-index 10 $upperBody
else
echo "POF results exist. Skip POF generation."
fi
# run Adam Fitting
cd $MTCDir/FitAdam/
if [ ! -f ./build/run_fitting ]; then
echo "C++ project not correctly compiled. Please check your setting."
fi
./build/run_fitting --root_dirs $dataDir --seqName $seqName --start 1 --end $((numFrame + 1)) --stage 1 --imageOF
# ./build/run_fitting --root_dirs $dataDir --seqName $seqName --start 1 --end 11 --stage 1 --imageOF