• Home
  • Help
  • Search
  • Login
  • Register
Pages: [1]
Author Topic: Success: webcam/IP-cam with image upload  (Read 3029 times)
tomplug
Newbie
*

Karma: 0
Posts: 15


View Profile
« on: September 02, 2010, 12:12:01 PM »

I wrote a little script that grabs images from a USB webcam and continuously uploads them to an image archiving site via FTP.  This turns the Plug into a little IP Surveillance camera connected to a cloud-based surveillance site.  I've also found this technique useful debugging as it allows me to view JPGs produced by Plug v4l software without needing to install GUI tools on the Plug.

About the script and my system.  Here is my system:

Linux debian 2.6.31.8 #1 PREEMPT Wed Apr 21 11:23:23 PHT 2010 armv5tel GNU/Linux

It already had ffmpeg and ftp installed.  I needed to install "dov4l" to control the video parameters.

apt-get install dov4l


About the camera.  I think only UVC (USB Video Class) cameras will work this way.  Here is the information printed in the console when I plug in my camera:

usb 1-1.2: new high speed USB device using orion-ehci and address 4
usb 1-1.2: configuration #1 chosen from 1 choice
uvcvideo: Found UVC 1.00 device VF0610 Live! Cam Socialize HD (041e:4080)
input: VF0610 Live! Cam Socialize HD as /devices/platform/orion-ehci.0/usb1/1-1/1-1.2/1-1.2:1.0/input/input1
4:3:1: cannot get freq at ep 0x82


A note about Sensr: Sensr is an image upload service.  It is a pure cloud-based solution for the storage and viewing of image streams.  You should probably go to Sensr and get your own account and allocate a new camera with your own FTP settings.  Once created, you can view the images from your camera on http://sensr.net.


Here is my script.  I think it is mostly self-explanatory.  I'm just learning about v4l, but I thought this was interesting and useful.


#!/bin/bash
#
# Prerequisites:
#   apt-get install dov4l
#   a UVC (USB Video Class) webcam

set -x

# Sensr FTP information
# View at http://sensr.net/
HOST=XX.sensr.net
USER=camXXX
PASS=XXXXXXXXXX

# Exit by hitting ^C
trap 'echo EXIT WEBCAM; exit 0'  SIGINT SIGTERM

# Get latest added video device
DEV=`ls /dev/video* | tail -1`

# Set image size
W=640
H=480

# Set size, framerate
dov4l -d ${DEV} -s ${W},${H}
dov4l -d ${DEV} -f 25

for (( ; ; ))
do

    # Get two frames.  First frame is usually dirty.
    ffmpeg -f video4linux2 -s ${W}x${H} -y -r 1 -t 2 -i ${DEV}  -f image2 "x%02d.jpg"

    if [ -f x02.jpg ]; then

        # Upload to Sensr via FTP method
   ftp -d -v -n ${HOST} <<EOF
quote user ${USER}
quote pass ${PASS}
binary
put x02.jpg
quit
EOF

   rm x02.jpg

    else
   sleep 1
    fi
done

exit 0


« Last Edit: September 03, 2010, 05:58:00 AM by tomplug » Logged

velo_love
Newbie
*

Karma: 0
Posts: 15


View Profile
« Reply #1 on: September 02, 2010, 02:03:35 PM »

Hi,

you should remove your login / password from the script you copy here  Wink
Logged

tomplug
Newbie
*

Karma: 0
Posts: 15


View Profile
« Reply #2 on: September 02, 2010, 02:39:15 PM »

A good idea!  I edited it out.
Logged

Pages: [1]
Print
Jump to: