/
installARToolKit.sh
executable file
·181 lines (156 loc) · 7.4 KB
/
installARToolKit.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
#!/bin/bash
#
# ARToolKit 2.72.1 installation script for Ubuntu
#
# Author: enekochan
# URL: https://github.com/enekochan
#
function readPrompt() {
while true; do
read -e -p "$1"": " -i "$2" result
case $result in
Y|y ) result="y"; break;;
N|n ) result="n"; break;;
* ) echo "Please answer yes or no.";;
esac
done
}
#Create the path for the log file and quote it
#so paths are correct for command line programs
LOG_FILE="\""`pwd`"/install.log\""
#rm $LOG_FILE >> /dev/null 2>> /dev/null
UBUNTU_VERSION=`cat /etc/lsb-release | grep RELEASE | awk -F= '{print $2}'`
eval "echo \"Detected Ubuntu "$UBUNTU_VERSION" system...\" 2>&1 | tee $LOG_FILE"
CPU_COUNT=`cat /proc/cpuinfo | grep processor | wc -l`
if [ $CPU_COUNT != "1" ]; then
CPU_COUNT="-j "$CPU_COUNT
else
CPU_COUNT=""
fi
#readPrompt "Downlad ARToolKit from the SVN repository? " "n"
#ARTOOLKITSVN=$result
readPrompt "Do you want to see verbose installation progress? " "n"
VERBOSE=$result
if [ $VERBOSE == "n" ]; then VERBOSE=" > /dev/null"; else VERBOSE=""; fi
DELETE_ARTOOLKIT_FOLDER="n"
if [ -d ARToolKit ]; then
readPrompt "ARToolKit folder already exists, should I overwrite it? " "n"
DELETE_ARTOOLKIT_FOLDER=$result
fi
readPrompt "Add V4L2 support to ARToolKit? " "y"
V4L2_SUPPORT=$result
#readPrompt "Add OpenKinect (libfreenect) support to ARToolKit? " "y"
#OPENKINECT_SUPPORT=$result
OPENKINECT_SUPPORT="n"
eval "echo \"Updating apt database (may ask for your password)\" 2>&1 | tee $LOG_FILE $VERBOSE"
eval "sudo apt-get update 2>&1 | tee $LOG_FILE $VERBOSE"
eval "echo \"Installing dependencies...\" 2>&1 | tee $LOG_FILE $VERBOSE"
if [ $UBUNTU_VERSION == "10.04" -o $UBUNTU_VERSION == "10.10" -o $UBUNTU_VERSION == "11.04" -o $UBUNTU_VERSION == "11.10" -o $UBUNTU_VERSION == "12.04" ];then
eval "sudo apt-get -y install freeglut3-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libxi-dev libxmu-headers libxmu-dev libjpeg62-dev libglib2.0-dev libgtk2.0-dev 2>&1 | tee $LOG_FILE $VERBOSE"
#elif [ $UBUNTU_VERSION == "XX.XX" ];then
# echo "XX.XX"
fi
if [ $DELETE_ARTOOLKIT_FOLDER == "y" ]; then
rm -Rf ARToolKit >> /dev/null 2>> /dev/null
fi
if [ ! -e ARToolKit ]; then
eval "wget \"http://sourceforge.net/projects/artoolkit/files/artoolkit/2.72.1/ARToolKit-2.72.1.tgz/download\" -O ARToolKit-2.72.1.tgz 2>&1 | tee $LOG_FILE $VERBOSE"
eval "tar xzvpf ARToolKit-2.72.1.tgz 2>&1 | tee $LOG_FILE $VERBOSE"
## Download from the SVN repository
# eval "sudo apt-get install -y subversion 2>&1 | tee $LOG_FILE $VERBOSE"
# eval "svn co https://artoolkit.svn.sourceforge.net/svnroot/artoolkit/trunk ARToolKit 2>&1 | tee $LOG_FILE $VERBOSE"
# eval "mv -f ./ARToolKit/artoolkit/* ./ARToolKit 2>&1 | tee $LOG_FILE $VERBOSE"
# eval "rm -fR ./ARToolKit/artoolkit 2>&1 | tee $LOG_FILE $VERBOSE"
###################################################################################
fi
cd ARToolKit
if [ $V4L2_SUPPORT == "y" -a $OPENKINECT_SUPPORT == "y" ]; then
if [ $UBUNTU_VERSION == "11.04" -o $UBUNTU_VERSION == "11.10" -o $UBUNTU_VERSION == "12.04" ];then
eval "patch -N -p1 -i ../Patches/ARToolKit/v4l2-Freenect-GST_LIBS.patch 2>&1 | tee $LOG_FILE $VERBOSE"
else
eval "patch -N -p1 -i ../Patches/ARToolKit/v4l2-Freenect.patch 2>&1 | tee $LOG_FILE $VERBOSE"
fi
elif [ $V4L2_SUPPORT == "y" ]; then
if [ $UBUNTU_VERSION == "11.04" -o $UBUNTU_VERSION == "11.10" -o $UBUNTU_VERSION == "12.04" ];then
eval "patch -N -p1 -i ../Patches/ARToolKit/artk-v4l2-2.72.1.20120613-GST_LIBS.patch 2>&1 | tee $LOG_FILE $VERBOSE"
else
eval "patch -N -p1 -i ../Patches/ARToolKit/artk-v4l2-2.72.1.20120613.patch 2>&1 | tee $LOG_FILE $VERBOSE"
fi
elif [ $OPENKINECT_SUPPORT == "y" ]; then
if [ $UBUNTU_VERSION == "11.04" -o $UBUNTU_VERSION == "11.10" -o $UBUNTU_VERSION == "12.04" ];then
eval "patch -N -p1 -i ../Patches/ARToolKit/Freenect-GST_LIBS.patch 2>&1 | tee $LOG_FILE $VERBOSE"
else
eval "patch -N -p1 -i ../Patches/ARToolKit/Freenect.patch 2>&1 | tee $LOG_FILE $VERBOSE"
fi
else
if [ $UBUNTU_VERSION == "11.04" -o $UBUNTU_VERSION == "11.10" -o $UBUNTU_VERSION == "12.04" ];then
eval "patch -N -p1 -i ../Patches/ARToolKit/GST_LIBS.patch 2>&1 | tee $LOG_FILE $VERBOSE"
#else
#
fi
fi
echo "Now you will be asked 3 questions to configure ARToolKit."
echo "First: You have to choose the input driver for ARToolKit (probably you should choose \"GStreamer Media Framework\")."
echo "Second: If you want debug simbols answer \"y\" to the next question."
echo "Third: If your graphics card supports texture rectangle or not."
./Configure
# This patch is common to all (fixes a problem with osgART)
eval "patch -N -p1 -i ../Patches/ARToolKit/VideoGStreamer.patch 2>&1 | tee $LOG_FILE $VERBOSE"
echo "Compiling ARToolKit..."
eval "echo \"Compiling ARToolKit...\" 2>&1 | tee $LOG_FILE"
eval "make $CPU_COUNT 2>&1 | tee $LOG_FILE $VERBOSE"
echo "Copying libraries and include files to your system..."
eval "sudo cp -R ./include/AR /usr/local/include/ 2>&1 | tee $LOG_FILE $VERBOSE"
eval "sudo cp ./lib/*.a /usr/local/lib/ 2>&1 | tee $LOG_FILE $VERBOSE"
eval "sudo cp -R ./bin/* /usr/local/bin/ 2>&1 | tee $LOG_FILE $VERBOSE"
rm AR.pc >> /dev/null 2>> /dev/null
touch AR.pc
echo "prefix=/usr/local" >> AR.pc
echo "exec_prefix=\${prefix}" >> AR.pc
echo "libdir=\${exec_prefix}/lib" >> AR.pc
echo "includedir=\${exec_prefix}/include" >> AR.pc
echo "" >> AR.pc
echo "Name: AR" >> AR.pc
echo "Description: ARToolKit libs and includes" >> AR.pc
echo "Version: 2.72.1" >> AR.pc
echo "Libs: -L\${libdir} -lARgsub -lARgsub_lite -lARgsubUtil -lARMulti -lARvideo -lAR" >> AR.pc
echo "Cflags: -I\${includedir}/AR" >> AR.pc
if [ -d "/usr/lib/pkgconfig/" ]; then
eval "sudo mv AR.pc /usr/lib/pkgconfig/ 2>&1 | tee $LOG_FILE $VERBOSE"
else
if [ -d "/usr/lib/pkg-config/" ]; then
eval "sudo mv AR.pc /usr/lib/pkg-config/ 2>&1 | tee $LOG_FILE $VERBOSE"
else
eval "echo \"Couldn't find path for pkgconfig folder. Continuing anyway...\" 2>&1 | tee $LOG_FILE"
fi
fi
if [ -c /dev/video* ]; then
ARTOOLKIT_BASHRC=`cat ~/.bashrc | grep ARTOOLKIT_CONFIG`
if [ "$ARTOOLKIT_BASHRC" != "" ]; then
eval "echo \"ARTOOLKIT_CONFIG variable is already defined in ~/.bashrc\" 2>&1 | tee $LOG_FILE"
eval "echo \"Please verify that it is pointing to one of those devices:\" 2>&1 | tee $LOG_FILE"
eval "echo \"\" 2>&1 | tee $LOG_FILE"
eval "ls -l /dev/video* | awk '{print $9}' 2>&1 | tee $LOG_FILE"
else
CAMERA=""
eval "echo \"Webcams installed in the system:\" 2>&1 | tee $LOG_FILE"
eval "echo \"\" 2>&1 | tee $LOG_FILE"
eval "ls -l /dev/video* | awk '{print $9}' 2>&1 | tee $LOG_FILE"
eval "echo \"\" 2>&1 | tee $LOG_FILE"
while [ $CAMERA -ne $CAMERA 2> /dev/null ] # Is it numeric?
do
read -p "Select a camera. For /dev/video0 write 0 and press enter: " CAMERA
if [ ! -c /dev/video$CAMERA ]; then
eval "echo \"/dev/video\"$CAMARA\" does not exist. 2>&1 | tee $LOG_FILE"
CAMERA=""
fi
done
eval "echo \"\" >> ~/.bashrc 2>&1 | tee $LOG_FILE"
echo "export ARTOOLKIT_CONFIG=\"v4l2src device=/dev/video$CAMERA use-fixed-fps=false ! ffmpegcolorspace ! capsfilter caps=video/x-raw-rgb,bpp=24 ! identity name=artoolkit ! fakesink\"" >> ~/.bashrc
fi
else
eval "echo \"Couldn't find any webcam connected to the system. You'll have to configure ARTOOLKIT_CONFIG yourself.\" 2>&1 | tee $LOG_FILE"
fi
eval "sudo ldconfig /etc/ld.so.conf 2>&1 | tee $LOG_FILE $VERBOSE"
eval "echo \"Installation complete.\" 2>&1 | tee $LOG_FILE"
exit