-
Notifications
You must be signed in to change notification settings - Fork 137
/
dump_and_process_video.sh
executable file
·93 lines (66 loc) · 3.48 KB
/
dump_and_process_video.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
DATASET=""
if (( $#<1 ))
then
echo "Please provide arguments first argument is dataset "
exit 1
else
DATASET=$1-data
fi
# $1 holds the video file we want to process ( it should be something like path/to/videofile.mp4 )
#DATASET now holds the output directory we will create ( it should be something like path/to/videofile.mp4-data/ )
#Remember the directory where user started
STARTDIR=`pwd`
#Remember the directory where the script is ( and where MocapNET is :) )
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#Please give the path to openpose here..
OPENPOSE_DIR="/home/ammar/Documents/3dParty/openpose/"
OPENPOSE_BINARY_DIR="/home/ammar/Documents/3dParty/openpose/build/examples/openpose/"
#Dataset dumping using ffmpeg
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#Create the new dataset directory
mkdir $DATASET
#Dump the video files using our naming scheme
ffmpeg -i $1 -r 30 -q:v 1 $DATASET/colorFrame_0_%05d.jpg
#Make sure we start at frame 0
cp $DATASET/colorFrame_0_00001.jpg $DATASET/colorFrame_0_00000.jpg
#We now want to grab an absolute path to our dataset
cd $DATASET
FULL_PATH_TO_DATASET=`pwd`
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#2D pose estimation using OpenPose
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
cd $OPENPOSE_DIR
LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64 $OPENPOSE_BINARY_DIR/openpose.bin -number_people_max 1 --hand --face --write_json $FULL_PATH_TO_DATASET -image_dir $FULL_PATH_TO_DATASET $@
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#2D pose conversion to CSV using our tool
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
cd "$DIR"
cd ..
./convertOpenPoseJSONToCSV --from $DATASET
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#3D pose estimation using MocapNET2
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
cd "$DIR"
cd ..
./MocapNET2CSV --from $FULL_PATH_TO_DATASET/2dJoints_v1.4.csv --mt --show 3 --save
cp out.bvh $FULL_PATH_TO_DATASET/predicted.bvh
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
cd $STARTDIR
exit 0