Mika Kulmala - Introduction to ITS in Tampere: Strategy and vision - Mindtrek 2016
Setting up linux webcam server Juho Launonen & Sami Kulmala.
-
Upload
theodora-norman -
Category
Documents
-
view
219 -
download
0
Transcript of Setting up linux webcam server Juho Launonen & Sami Kulmala.
Setting up linux webcam server
Juho Launonen & Sami Kulmala
At the beginning we...
Created new virtual machine with default settings and linux debian distro
Installed apache and loads of other stuff Connected webcam Got nice feed from the camera Tried to set up the server
Then the problems started
It appeared that the v4l (video for linux), which is a video capture application programming interface for Linux, did not work for us at all
That's when the shit hit the fan Nothing was working properly and we were
desperate After 16 hours and thousands of useless attempts
it was time to start all over again with a new distro...
Installing Ubuntu
So...
Ubuntu server was succesfully installed with GUI Apache was installed
sudo apt-get install apache2
Webcam server package sudo apt-get install webcam-server
Configuration
We had to make startup script for the webcam server so that we could control it as a daemon and start it at startup
We made the following script to the /etc/init.d directory...
#!/bin/sh
SERVER_BIN=webcam-serverLOCK_FILE=/var/lock/$SERVER_BINRTRN=0OPTIONS='-v -g 640x480 -p 8888 -c JUMI'
start() {
[ -f $LOCK_FILE ] && echo "$SERVER_BIN already started"[ -f $LOCK_FILE ] && return
echo -n "Starting $SERVER_BIN: "export LD_PRELOAD=/usr/lib/libv4l/v4l1compat.sonohup $SERVER_BIN $OPTIONS > /dev/null 2>/dev/null &RTRN=$?[ $RTRN -eq 0 ] && echo Started! || echo FAIL[ $RTRN -eq 0 ] && touch $LOCK_FILE}
stop() {[ -f $LOCK_FILE ] || echo "$SERVER_BIN is not running"[ -f $LOCK_FILE ] || returnecho -n "Stopping $SERVER_BIN: "pkill -f "$SERVER_BIN $OPTIONS"RTRN=$?rm -f $LOCK_FILE[ $RTRN -eq 0 ] && echo Stopped! || echo FAIL}
case "$1" instart)start;;stop)stop;;restart)stopstart;;*)echo "Usage: $0 {start|stop|restart}"RTRN=1esac
exit $RTRN
Configuration
With following commands we made the startup script run when Ubuntu starts up
sudo chmod +x /etc/init.d/webcam-server sudo update-rc.d webcam-server defaults
Now everything was ready for a little test so we started the webcam server
sudo /etc/init.d/webcam-server start
IT'S WORKING!
Juho was pretty scared when he realized that
http://localhost:8888/
Webcam stream to a webpage
To use the webcam stream on a webpage we had to copy the necessary java files to our webroot
sudo cp /usr/share/doc/webcam-server/applet/* /var/www/
Then we made webpages with following applet for the camera
<APPLET CODE = "WebCamApplet.class" archive="applet.jar" WIDTH = "640" HEIGHT = "480">
<param name=URL value="http://<OUR_IP>:8888">
<param name=FPS value="60">
<param name=width value="640">
<param name=height value="480">
</APPLET>
That's it!
Now lets see that amazing site!