-
Notifications
You must be signed in to change notification settings - Fork 48
/
vsfm_os_x_installer.sh
executable file
·449 lines (360 loc) · 12.2 KB
/
vsfm_os_x_installer.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
#!/bin/bash
# Visual SFM installer for OS X
#
# Copyright Dan Monaghan 2014 www.luckybulldozer.com
#
# Please check out our short film Sifted at http://www.vimeo.com/69136384
#
# Should be as simple as it gets!
#
# To run, cd into the directory of the installer and simply execute this script via…
# sh vsfm_os_x_installer_mavericks.sh
#
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
# Credits go to Changchang Wu for VisualSFM
# Structure from Motion
# [1] Changchang Wu, "Towards Linear-time Incremental Structure From
# Motion", 3DV 2013
# [2] Changchang Wu, "VisualSFM: A Visual Structure from Motion System",
# http://ccwu.me/vsfm/, 2011
#
# + Bundle Adjustment
# [3] Changchang Wu, Sameer Agarwal, Brian Curless, and Steven M. Seitz,
# "Multicore Bundle Adjustment", CVPR 2011
#
#
# Feature Detection
# [4] Changchang Wu, "SiftGPU: A GPU implementation of Scale Invaraint
# Feature Transform (SIFT)", http://cs.unc.edu/~ccwu/siftgpu, 2007
#
#
# PMVS2 Yasutaka Furukawa http://www.cs.washington.edu/homes/furukawa/
#
# [Initial Cmake multiplatform port ] Pierre moulon pmoulon[AT]gmail.com
# [CMVS/PMVS] http://http://grail.cs.washington.edu/software/cmvs/
# [CMake version] http://opensourcephotogrammetry.blogspot.com/
# https://github.com/TheFrenchLeaf/CMVS-PMVS
#
# Graclus -- Efficient graph clustering software for normalized cut and ratio association on undirected graphs.
#
# Copyright(c) 2008 Brian Kulis, Yuqiang Guan (version 1.2)
#
# http://www.cs.utexas.edu/users/dml/Software/graclus.html/
#
# Homebrew
#
# http://mxcl.github.com/homebrew/
#
#
# Big thanks for Iván Rodríguez Murillo's original OS X installer
# https://github.com/iromu
#### Let the script begin.
# check if script has been run as root, it shouldn't be.
if [[ $EUID -eq 0 ]]; then
echo "This script should not need to be run as root. Exiting"
exit 1
fi
# function Declarations defined below...
function lineBreak (){
echo ""
}
function echoGood () {
#echos green text to stand out for succesful execution of a task
# ... hmmm default os x terminal is green text...
INPUT_TEXT=$1
printf "\e[0;32m${INPUT_TEXT}\e[0m\n"
}
function echoBad () {
#echos red text to stand out for a fail/warning
INPUT_TEXT=$1
printf "\e[0;31m${INPUT_TEXT}\e[0m\n"
}
function checkBrew() {
#check if a particualar brew is installed - not used much as brew does this pretty well already.
if which $1 >/dev/null;
then
echo "$1 is already installed, OK"
else
echo "$1 is not installed... brewing now."
brew install $1
fi
}
function installBrews () {
brew install jpeg
brew install gdk-pixbuf --cc=llvm-gcc
brew install cairo --with-x11
brew install freetype
brew link freetype
brew install pango
brew link pixman
brew link fontconfig
brew install https://raw.githubusercontent.com/Homebrew/homebrew/99126a50c96b3c832d72f4531c116271f543eded/Library/Formula/gtk+.rb
brew install glew
brew install gsl
brew install boost
brew install intltool
brew install cmake
brew tap homebrew/versions
brew install gcc49
brew install devil
brew install pkg-config
#maybe....
# brew install mesalib-glw
}
function installXcodeSelect () {
echoGood "About to install xcode select"
echoBad "Hit Enter after it's installed"
xcode-select --install
}
############## int main.... lol
echo ""
echoGood "Dan Monaghan's VSFM and PMVS installer for OS X"
echo ""
echo "About to check to see if you have the Brew Package Manager"
if which brew >/dev/null;
then
echoGood "Great, you've got brew... Continuing"
else
echoGood "No, Ok I will install brew... you'll have to enter your root password if Xcode command line tools are needed to complete."
# old path ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
checkBrew wget
#checkBrew function defined at bottom
#instal xcode select
installXcodeSelect
# check to see if we have the right XQuartz....
echo "Checking we have the right version of XQuartz"
xquartz="2.7.8"
echo ""
cat /Applications/Utilities/XQuartz.app/Contents/Info.plist | awk '/<key>CFBundleShortVersionString<\/key>/{getline; print}' | grep $xquartz && xquartz_version_result="0" || echo xquartz_version_result="1"
echo "xquartz_version_result=$xquartz_version_result"
if [ "$xquartz_version_result" != "0" ]
then
echoBad "We must download the right version of XQuartz: $xquartz ... one moment while we install"
wget http://xquartz.macosforge.org/downloads/SL/XQuartz-$xquartz.dmg
open XQuartz-$xquartz.dmg
echo "Switch to Finder and install XQuartz as per the installer. Then log in and out and then run script 2"
else
echoGood "Your version of XQuartz is $xquartz - perfect."
fi
lineBreak; echo "Ok, now you have to should have either...";lineBreak
echo "1. Already had the correct version of XQuartz, so I'm continuing...";lineBreak
echo "2. Had to have installed XQuartz and just logged out and back in...";lineBreak
echo "Ready to continue the next installation of VSFM & PMVS (press ENTER)";lineBreak
read nothing
echo "Installing Brew packages... this can take quite a long time"
#############
installBrews
#############
# installing VSFM Section
function installVSFM () {
VSFM_ZIP=VisualSFM_osx_64bit.zip
VSFM_SRC=http://ccwu.me/vsfm/download/VisualSFM_osx_64bit.zip
if [[ ! -f $VSFM_ZIP ]]; then
echoBad "VSFM Zip not present, downloading..."
wget $VSFM_SRC -O VisualSFM_osx_64bit.zip
unzip $VSFM_ZIP
else
echoGood "Zip file is present, so just unzipping, removing old dir to install so we don't have any conflicts"
rm -fR vsfm
unzip $VSFM_ZIP
fi
cd vsfm
####### makefile Patches
echo "Changing VSFM GCC to Brews gcc-4.9"
S=$(echo CC = g++ -w | sed -e 's/\//\\\//g')
R=$(echo CC = g++-4.9 -w | sed -e 's/\//\\\//g')
sed -i '' -e "s/${S}/${R}/" makefile
echo "Changing /usr/x11/lib to OS X default /opt/x11/lib"
S=$(echo -L/usr/x11/lib | sed -e 's/\//\\\//g')
R=$(echo -L/opt/X11/lib | sed -e 's/\//\\\//g')
sed -i '' -e "s/${S}/${R}/" makefile
echoGood "About to make..."
make -f makefile
if [[ $? -eq 0 ]]; then
echoGood "VSFM application built... moving on"
else
echoBad "VSFM application failed to build, halting."
exit
fi
cd ..
}
#############
installVSFM
#############
function installSiftGPU () {
SIFT_GPU_SRC=http://wwwx.cs.unc.edu/~ccwu/cgi-bin/siftgpu.cgi
SIFT_GPU_ZIP=sift_gpu.zip
if [[ ! -f $SIFT_GPU_ZIP ]]; then
echoBad "SiftGPU Zip not present, downloading..."
wget $SIFT_GPU_SRC -O $SIFT_GPU_ZIP
unzip $SIFT_GPU_ZIP
else
echo "LIB_SIFT_GPU is present, skipping download and unzip. removing old dir to install so we don't have any conflicts"
rm -fR SiftGPU
unzip $SIFT_GPU_ZIP
fi
cd SiftGPU
####### makefile Patches
# echo "Changing SiftGPU GCC to Brews gcc-4.9"
# S=$(echo CC = g++ | sed -e 's/\//\\\//g')
# R=$(echo CC = g++-4.9 -w | sed -e 's/\//\\\//g')
# sed -i '' -e "s/${S}/${R}/" makefile
echo "Disable Cuda Flags"
S=$(echo siftgpu_enable_cuda = 1 | sed -e 's/\//\\\//g')
R=$(echo siftgpu_enable_cuda = 0 | sed -e 's/\//\\\//g')
sed -i '' -e "s/${S}/${R}/" makefile
echo "Changing march from native core2 in makefile"
S=$(echo native | sed -e 's/\//\\\//g')
R=$(echo core2 | sed -e 's/\//\\\//g')
sed -i '' -e "s/${S}/${R}/" makefile
echo "Changing to prefer GLUT"
S=$(echo siftgpu_prefer_glut = 0 | sed -e 's/\//\\\//g')
R=$(echo siftgpu_prefer_glut = 1 | sed -e 's/\//\\\//g')
sed -i '' -e "s/${S}/${R}/" makefile
echo "Removing -L/opt/local/lib from makefile"
S=$(echo -L/opt/local/lib | sed -e 's/\//\\\//g')
R=$(echo | sed -e 's/\//\\\//g')
sed -i '' -e "s/${S}/${R}/" makefile
echo "Changing /usr/x11/lib to OS X default /opt/x11/lib"
S=$(echo -L/usr/x11/lib | sed -e 's/\//\\\//g')
R=$(echo -L/opt/X11/lib | sed -e 's/\//\\\//g')
sed -i '' -e "s/${S}/${R}/" makefile
echo "Disable TestWin build for this OS X build"
S=$(echo '$(CC) -o $(BIN_DIR)/TestWinGlut $(SRC_TESTWIN) $(LIBS_DRIVER) $(CFLAGS)' | sed -e 's/\//\\\//g')
R=$(echo | sed -e 's/\//\\\//g')
sed -i '' -e "s/${S}/${R}/" makefile
make siftgpu
if [[ $? -eq 0 ]]; then
echoGood "libsiftgpu.so built... moving on"
else
echoBad "libsiftgpu.so failed to build. Halting."
exit
fi
cd ..
}
#############
installSiftGPU
#############
function installPBA () {
LIB_PBA_SRC=http://grail.cs.washington.edu/projects/mcba/pba_v1.0.5.zip
LIB_PBA_ZIP=pba_v1.0.5.zip
if [[ ! -f $LIB_PBA_ZIP ]]; then
echo "VSFM Zip not present, downloading..."
wget $LIB_PBA_SRC -O $LIB_PBA_ZIP
unzip $LIB_PBA_ZIP
else
echo "LIB_PBA is present, skipping download and unzip, removing old dir to install so we don't have any conflicts"
rm -fR pba
unzip $LIB_PBA_ZIP
fi
cd pba
####### makefile_no_gpu Patches
echo "Changing SiftGPU GCC to Brews gcc-4.9"
S=$(echo CC = g++ | sed -e 's/\//\\\//g')
R=$(echo CC = g++-4.9 -w | sed -e 's/\//\\\//g')
sed -i '' -e "s/${S}/${R}/" makefile_no_gpu
echo "Removing /usr/lib64 from makefile"
S=$(echo /usr/lib64 | sed -e 's/\//\\\//g')
R=$(echo | sed -e 's/\//\\\//g')
sed -i '' -e "s/${S}/${R}/" makefile_no_gpu
echo "Changing march from native core2 in makefile"
S=$(echo native | sed -e 's/\//\\\//g')
R=$(echo core2 | sed -e 's/\//\\\//g')
sed -i '' -e "s/${S}/${R}/" makefile_no_gpu
echo "Adding -L/usr/include/sys/ to compile Flags"
S=$(echo -L/usr/lib | sed -e 's/\//\\\//g')
R=$(echo -L/usr/lib -L/usr/include/sys/ | sed -e 's/\//\\\//g')
sed -i '' -e "s/${S}/${R}/" makefile_no_gpu
cp ../patches/SparseBundleCPU.patch src/pba/
cd src/pba
patch < SparseBundleCPU.patch
cd ../..
echoGood $PWD
make -f makefile_no_gpu pba
if [[ $? -eq 0 ]]; then
echoGood "libpba.so built... moving on"
else
echoBad "libpba.so failed to build, halting."
exit
fi
cd ..
}
#############
installPBA
#############
function installPMVS () {
PMVS_ZIP=PMVS_pmoulonGit.zip
PMVS_SRC=https://github.com/pmoulon/CMVS-PMVS/archive/master.zip
if [[ ! -f $PMVS_ZIP ]]; then
echoBad "PMVS Zip not present, downloading..."
wget $PMVS_SRC -O $PMVS_ZIP
unzip $PMVS_ZIP
else
echoGood "Zip file is present, so just unzipping, removing old dir to install so we dont have any conflicts"
rm -fR CMVS-PMVS-master
unzip $PMVS_ZIP
fi
cd CMVS-PMVS-master/program
patch base/stann/dpoint.hpp < ../../patches/dpoint_err.patch
####### CMakeLists.txt Patches
echo "Adding set CMAKE_EXE_LINKER_FLAGS -static-libgcc -static-libstdc++ to cmake flags"
cat ../../patches/cflag_var > temp
cat CMakeLists.txt >> temp
mv CMakeLists.txt OLD_CMakeLists
mv temp CMakeLists.txt
mkdir build
cd build
echoGood $PWD
cmake . ..
make
if [[ $? -eq 0 ]]; then
echoGood "CMVS & PMVS built... moving on"
else
echoBad "libpba.so failed to build, halting...."
exit
fi
cd ../../..
echoGood $PWD
}
#############
installPMVS
#############
function makeVSFMdir () {
cp pba/bin/libpba_no_gpu.so vsfm/bin/libpba.so
cp SiftGPU/bin/libsiftgpu.so vsfm/bin/
cp CMVS-PMVS-master/program/build/main/pmvs2 vsfm/bin
cp CMVS-PMVS-master/program/build/main/genOption vsfm/bin
cp CMVS-PMVS-master/program/build/main/cmvs vsfm/bin
}
#############
makeVSFMdir
#############
if [[ $? -eq 0 ]]; then
echoGood "Success! Opening VSFM dir"
echoBad "To add to your PATH, add the lines below to your ~/.bash_profile file."
echoBad "export PATH=$PWD/vsfm/bin:\$PATH"
echoBad "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$PWD"
echoGood "Make sure you ammend that that path if you move the directory."
open vsfm/bin/
else
echoBad "Failure. End of script"
exit
fi
### END OF SCRIPT