Webcam Tips
Jump to navigation
Jump to search
Here's a rough (there must be a thing or two I've forgotten but I think I was pretty thorough) outline for how to get the web cam for Barrow setup.
Here's an easy script to pull images from an Axis Q6032-E pan-tilt-zoom web cam.
#!/bin/bash ## Pan Range: -180 to +180 ## Tilt Range: -20 to +200 ## Zoom Range: 1 - 9999 wget --no-check-certificate -O /dev/null https://user:pass@axis-00408cb14f01.iarc.uaf.edu/axis-cgi/com/ptz.cgi?pan=-100&tilt=10&zoom=1 sleep 5 wget --no-check-certificate -r -O /home/bob/working_files/barrow/webcam1/images/view1.jpg https://axis.iarc.uaf.edu/jpg/image.jpg wget --no-check-certificate -O /dev/null https://axis.iarc.uaf.edu/axis-cgi/com/ptz.cgi?pan=-120&tilt=10&zoom=01 sleep 5 wget --no-check-certificate -r -O /home/bob/working_files/barrow/webcam1/images/view2.jpg https://user:pass@axis-00408cb14f01.iarc.uaf.edu/jpg/image.jpg wget --no-check-certificate -O /dev/null https://axis.iarc.uaf.edu/axis-cgi/com/ptz.cgi?pan=100&tilt=10&zoom=35 sleep 5 wget --no-check-certificate -r -O /home/bob/working_files/barrow/webcam1/images/view3.jpg https://axis.iarc.uaf.edu/jpg/image.jpg
To view these images on the remote server you're running the script from, presuming imagemagick is installed:
First:
ssh -Y to the server
Second:
$ display view1.jpg
Here is one way to set up a DreamPlug to control this camera (also doubles as serial server):
- Log in as root (nosoup4u)
- passwd (change password)
- mkdir /home/bob
- adduser bob
- chown bob:bob /home/bob
- su bob
- mkdir .ssh
- cd .ssh
- ssh-keygen -t rsa -b 2048
- update /etc/apt/sources.list (backports.debian.org & comment out the internal ip line)
- apt-get update
- apt-get upgrade
- cat id_rsa.pub # copy the key
- ssh bob@datapro.iarc.uaf.edu
- cd .ssh
- paste key to /home/bob/.ssh/authorized_keys
- Disable wireless adapter: http://www.spinifex.com.au/plugs/dphowtowifiap.html
- Modify /etc/network/interfaces
auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp auto eth1 iface eth1 inet static address 192.168.1.1 broadcast 192.168.1.255 netmask 255.255.255.0 network 192.168.1.0
- apt-get install less
- apt-get install nmap
- apt-get install imagemagick
- apt-get remove samba
- apt-get remove alsa-utils
- apt-get remove lighttpd
- apt-get remove ftpd
- SSH Port: 22
- add user to sudoers:
- chmod 4755 /usr/bin/sudo
- give general user crontab permissions:
- chmod 4755 /usr/bin/crontab
- DHCP Server is: udhcpd (default... added dhcp3 & dnsmasq and it confused things)
- To give axis camera a static IP over DHCP:
static_lease 00:40:8c:b1:4f:01 192.168.1.3 (in /etc/udhcpd.conf)
- to make the name known (dream2012.iarc.uaf.edu)
nano /etc/dhcp3/dhclient.conf /send host-name "dream2012";
- to map the removable SD card modify /etc/fstab
/dev/sdb1 /var/pictures/ ext2 rw,noatime 0 0
- ser2net.conf config:
7808:raw:60:/dev/ttyUSB0:9600 8DATABITS NONE 1STOPBIT 7809:raw:60:/dev/ttyUSB1:9600 8DATABITS NONE 1STOPBIT
- IP Tables setup (This may not quite be up to date):
dream2012:~# iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- anywhere anywhere tcp dpt:ssh ACCEPT tcp -- anywhere anywhere tcp dpt:7808 ACCEPT tcp -- anywhere anywhere tcp dpt:7809
Cron
bob@dream2012:~/bin$ cat main_cron #* * * * * command to be executed #- - - - - #| | | | | #| | | | +----- day of week (0 - 6) (Sunday=0) #| | | +------- month (1 - 12) #| | +--------- day of month (1 - 31) #| +----------- hour (0 - 23) #+------------- min (0 - 59) 4,34 * * * * /usr/local/bin/xmitip.sh 0,15,30,45 * * * * /usr/local/bin/webcam1.sh
/usr/local/bin/xmitip.sh
#!/bin/bash ifconfig > /home/bob/bin/brw_dp_ip.txt scp -i /home/bob/.ssh/id_rsa /home/bob/bin/brw_dp_ip.txt bob@datapro.iarc.uaf.edu:/home/bob/working_files/barrow/dreamplug/
/usr/local/bin/webcam1.sh
bob@dream2012:~$ cat /usr/local/bin/webcam1.sh #!/bin/bash ## Pan Range: -180 to +180 ## Tilt Range: -20 to +200 ## Zoom Range: 1 - 9999 # date for filenames datez=$(date +%Y_%j_%H%I%M) # set some directory related things rootdir="/var/pictures/webcam1/" yearz=$(date +%Y) mkdir "${rootdir}view1/${yearz}" mkdir "${rootdir}view2/${yearz}" mkdir "${rootdir}view3/${yearz}" picture1="${rootdir}/view1/${yearz}/${datez}-vw1.jpg" wget --no-check-certificate -O /dev/null https://guruplug:PUlse23@192.168.1.3/axis-cgi/com/ptz.cgi?pan=-100&tilt=10&zoom=1 sleep 5 wget --no-check-certificate -r -O $picture1 https://guruplug:PUlse23@192.168.1.3/jpg/image.jpg picture2="${rootdir}/view2/${yearz}/${datez}-vw2.jpg" wget --no-check-certificate -O /dev/null https://guruplug:PUlse23@192.168.1.3/axis-cgi/com/ptz.cgi?pan=-120&tilt=10&zoom=01 sleep 5 wget --no-check-certificate -r -O $picture2 https://guruplug:PUlse23@192.168.1.3/jpg/image.jpg picture3="${rootdir}/view3/${yearz}/${datez}-vw3.jpg" wget --no-check-certificate -O /dev/null https://guruplug:PUlse23@192.168.1.3/axis-cgi/com/ptz.cgi?pan=100&tilt=10&zoom=35 sleep 5 wget --no-check-certificate -r -O $picture3 https://guruplug:PUlse23@192.168.1.3/jpg/image.jpg rsync -avz -e "ssh -i /home/bob/.ssh/id_rsa" /var/pictures/webcam1/view1/* bob@datapro.iarc.uaf.edu:/home/bob/working_files/barrow/webcam1/view1/ rsync -avz -e "ssh -i /home/bob/.ssh/id_rsa" /var/pictures/webcam1/view2/* bob@datapro.iarc.uaf.edu:/home/bob/working_files/barrow/webcam1/view2/ rsync -avz -e "ssh -i /home/bob/.ssh/id_rsa" /var/pictures/webcam1/view3/* bob@datapro.iarc.uaf.edu:/home/bob/working_files/barrow/webcam1/view3/
Other hand commands from this setup:
service --status-all
Handy: //dpkg --get-selections | grep ftp// useful to see what extra stuff is installed. (e.g. mysql, ftpd, samba)