-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun_pipeline.sh
161 lines (130 loc) · 5.71 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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/bash
# run this script under the directory of monodepth2
# you may need to first put all the test images in a test_images folder under assets/
# you will get the depth output for monodepth presentation, o3d and infiniTAM
function reconstruct_o3d() {
# move scene image and o3d depth to o3d reconstruction pipeline
mkdir $dir/Reconstruction_o3d/ReconstructionSystem/dataset/kitti_1
cp -r $dir/DepthPrediction/assets/test_images/ $dir/Reconstruction_o3d/ReconstructionSystem/dataset/kitti_1/image/
cp -r $dir/DepthPrediction/assets/output_depth_o3d/ $dir/Reconstruction_o3d/ReconstructionSystem/dataset/kitti_1/depth/
echo "===================================="
echo "Start Reconstruction Using Open3d"
echo "===================================="
cd $dir/Reconstruction_o3d/ReconstructionSystem/ || exit
python run_system.py $dir/Reconstruction_o3d/ReconstructionSystem/config/kitti_1.json --make --register --refine --integrate
echo "===================================="
echo "Visualize Reconstruction"
echo "===================================="
cd $dir/src || exit
python pcd_vis.py --scene_path $dir/Reconstruction_o3d/ReconstructionSystem/dataset/kitti_1/scene/integrated.ply --ext ply
}
function reconstruct_infinitam() {
# first need to convert rgb to ppm format and depth to pgm format
echo "===================================="
echo "Convert depth and rgb image to infinitam format"
echo "===================================="
cp -r $dir/DepthPrediction/assets/test_images/ $dir/DepthPrediction/assets/output_rgb_infinitam/
cd $dir/DepthPrediction/assets/output_rgb_infinitam/ && magick mogrify -format ppm *.png
cd $dir/DepthPrediction/assets/output_depth_infinitam/ && magick mogrify -format pgm *.png
echo "===================================="
echo "Done"
echo "===================================="
# run InfiniTAM
echo "===================================="
echo "Start Reconstruction Using InfiniTAM"
echo "===================================="
# shellcheck disable=SC2164
cd $dir/Reconstruction/InfiniTAM/build/Apps/InfiniTAM/
./InfiniTAM $dir/Reconstruction/InfiniTAM/kitti/calib3.txt \
$dir/DepthPrediction/assets/output_rgb_infinitam/%04i.ppm \
$dir/DepthPrediction/assets/output_depth_infinitam/%04i.pgm
echo "===================================="
echo "Reconstruction Finished"
echo "===================================="
echo "===================================="
echo "Visualize Reconstruction"
echo "===================================="
cd $dir/src || exit
python pcd_vis.py --scene_path $dir/Reconstruction/InfiniTAM/build/Apps/InfiniTAM/color_mesh.obj --ext obj
}
function auto_ar_followup() {
echo "===================================="
echo "AUTO MODE FOR AR"
echo "===================================="
# shellcheck disable=SC2164
cd $dir/AR/
blender -b --python auto_follow_up.py --\
--obj_dir $dir/AR/scaled_objs \
--obj "Bus" \
--bg $dir/AR/subscenes/ \
--env $dir/AR/hdrs/ \
--out $dir/AR/outputs/ \
--pose $dir/AR/poses/ \
--light $dir/AR/light.txt
}
echo "===================================="
echo "Set up folders for specific outputs"
echo "===================================="
export dir=$PWD
mkdir $dir/DepthPrediction/assets/output_depth_rendering/
mkdir $dir/DepthPrediction/assets/output_depth_infinitam/
mkdir $dir/DepthPrediction/assets/output_npy_mono/
mkdir $dir/DepthPrediction/assets/output_depth_o3d/
## Rename the name of the image from 10-digits to 4
## Only need to run ONCE for a new dataset
#for file in ./DepthPrediction/assets/test_images/*
#do
# lastfour=${file:23}
## lastfour="${file:27:30}"
# filename=${file:0:21}$lastfour
# echo $filename
#
# mv $file $filename
#done
echo "===================================="
echo "Render input rgb images to video"
echo "===================================="
cd $dir/src || exit
python pic2video.py --image_path $dir/DepthPrediction/assets/test_images/ --output_name input.mp4
echo "===================================="
echo "See rendered video under src directory"
echo "===================================="
echo "===================================="
echo "Depth Prediction Started"
echo "===================================="
for file in $dir/DepthPrediction/assets/test_images/*; do
cd $dir/DepthPrediction/ || exit
python test_simple.py --image_path $file --output_depth $dir/DepthPrediction/assets/output_depth_rendering/ \
--output_npy $dir/DepthPrediction/assets/output_npy_mono/ \
--output_depth_o3d $dir/DepthPrediction/assets/output_depth_o3d/ \
--output_depth_infi $dir/DepthPrediction/assets/output_depth_infinitam/ \
--model_name mono_1024x320 \
--no_cuda
done
echo "===================================="
echo "Depth Prediction Finished"
echo "===================================="
echo "===================================="
echo "Render output depth images to video"
echo "===================================="
cd $dir/src || exit
python pic2video.py --image_path $dir/DepthPrediction/assets/output_depth_rendering/ --output_name depth.mp4
echo "===================================="
echo "See rendered video under src directory"
echo "===================================="
read -r -p "Do you want to reconstruct using Open3d? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
reconstruct_o3d
fi
read -r -p "Do you want to reconstruct using InfiniTAM? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
reconstruct_infinitam
fi
read -r -p "Do you want to use Blender script to automatically generate AR images? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
auto_ar_followup
fi
wait
echo "===================================="
echo "All Done"
echo "===================================="