User Tools

Site Tools


doc:howto:webcam

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
doc:howto:webcam [2012/09/25 18:22]
lizby
doc:howto:webcam [2016/07/11 16:43] (current)
beard
Line 1: Line 1:
 +===== Webcam with the Linux UVC driver =====
 +See [[usb.video|USB Video Support]]
  
 +[[wp>USB video device class]]
 +
 +
 +===== Prerequisites =====
 +
 +  - follow [[usb.essentials]]
 +  - follow [[usb.video]]
 +
 +^ Name ^ Depends ​ ^  Size  ^ Description ​ ^
 +| mjpg-streamer ​  | libpthread, libjpeg |  33738 | Streaming application for Linux-UVC compatible webcams ​ |
 +
 +The package [[man>​motion]] is <​del>​not</​del>​ now available in the OpenWrt repositories. http://​www.lavrsen.dk/​foswiki/​bin/​view/​Motion/​WebHome
 +
 +
 +===== Installation =====
 +<​code>​
 +opkg install kmod-video-uvc mjpg-streamer
 +</​code>​
 +
 +===== Configuration =====
 +->''​[[doc:​uci:​mjpg-streamer|/​etc/​config/​mjpg-streamer]]''​
 +
 +Don't forget change option enabled '​0'​ to '​1'​.
 +===== Usage =====
 +  * start on boot<​code>​
 +/​etc/​init.d/​mjpg-streamer enable
 +</​code>​
 +  * start ''​mjpg-streamer''​ right now<​code>​
 +/​etc/​init.d/​mjpg-streamer start
 +</​code>​
 +
 +**NOTE:** You will need to edit the mjpeg config to enable the mjpeg streamer. Manually edit the /​etc/​config/​mjpeg-streamer file.
 +
 +Now open the URL http://​192.168.1.1:​8080/​ in the Firefox browser or VLC and watch the MJPEG stream (the default username/​password is "​openwrt"/"​openwrt"​). In other browsers, scripts, etc., you can use http://​192.168.1.1:​8080?​action=snapshot for taking one image or http://​192.168.1.1:​8080?​action=stream for stream of images.
 +
 +===== Performance =====
 +
 +mjpeg-streamer fps, CPU load, memory usage, bandwidth at different resolutions:​
 +
 +  * [[https://​forum.openwrt.org/​viewtopic.php?​pid=296414#​p296414|USB HD camera module (vid=05a3, pid=9230)]]
 +  * [[https://​forum.openwrt.org/​viewtopic.php?​pid=296534#​p296534|Logitech HD Pro C920 (vid=046d, pid=082d)]]
 +
 +===== Embedding video stream into simple webpages =====
 +
 +  * Download a package located [[http://​mjpg-streamer.svn.sourceforge.net/​viewvc/​mjpg-streamer/​mjpg-streamer/​www/​| here]] and unpack it into /​www/​webcam_www directory.
 +  * Edit /​etc/​init.d/​mjpg-streamer - find this line in function start():
 +<​code>​
 +[ $enabled -gt 0 -a -c $device ] && sleep 3 && $SSD -S -m -p $PIDF -q -x $PROG -- --input "​input_uvc.so --device $device --fps $fps --resolution $resolution"​ --output "​output_http.so --port $port" &
 +</​code>​ and add //-w /​www/​webcam_www//​ behind --output "​output_http.so. Now it should look like this:
 +<​code>​
 +[ $enabled -gt 0 -a -c $device ] && sleep 3 && $SSD -S -m -p $PIDF -q -x $PROG -- --input "​input_uvc.so --device $device --fps $fps --resolution $resolution"​ --output "​output_http.so -w /​www/​webcam_www --port $port" &
 +</​code> ​
 +  * Now restart mjpg-streamer and open the URL http://​192.168.1.1:​8080/​ in your web browser.
 +
 +===== Controlling exposure, color balance, etc. =====
 +
 +The opkg version of mjpg-streamer has no control options for the camera. If you want to control exposure, brightness and other options you'll need to install uvcdynctrl.
 +
 +Install uvcdynctrl
 +<​code>​opkg install uvcdynctrl</​code>​
 +
 +List available devices.
 +
 +<​code>/​usr/​bin/​uvcdynctrl -l
 +</​code>​
 +
 +List available control options.
 +
 +<​code>/​usr/​bin/​uvcdynctrl -c
 +
 +Listing available controls for device video0:
 +  Brightness
 +  Contrast
 +  Saturation
 +  Hue
 +  White Balance Temperature,​ Auto
 +  Gamma
 +  Power Line Frequency
 +  White Balance Temperature
 +  Sharpness
 +  Backlight Compensation
 +
 +
 +</​code> ​
 +
 +Create a configuration file based on the current running values.
 +
 +<​code>/​usr/​bin/​uvcdynctrl -W /​etc/​config/​uvcdynctrl</​code>​
 +
 +Load a configuration file, which can be edited.
 +
 +<​code>/​usr/​bin/​uvcdynctrl -L /​etc/​config/​uvcdynctrl</​code>​
 +
 +The above can be added to /​etc/​rc.local,​ via the GUI or command line to load settings required for your camera. I use the above to enable auto exposure and auto white balance which would otherwise be disabled from cold a start.
 +
 +
 +
 +
 +
 +===== Webcam Pan and Tilt Example with Microprocessor =====
 +Here is a writeup of using openWrt for a pan and tilt camera. ​ The devices were NSLU2 for openWrt and Picaxe for microcontroller,​ but the idea is the same with arduino as micro and other openWrt devices:
 +
 +http://​www.picaxeforum.co.uk/​showthread.php?​13705
 +
 +Grey day today here in Nova Scotia, you can see at http://​www.lyzby.com/​cam.html
 +
 +===== Troubleshooting =====
 +
 +If the control page doesn'​t contain any of the controls, edit the file /​etc/​init.d/​mjpg-streamer and replace these lines
 +
 +<​code>​
 +service_start /​usr/​bin/​mjpg_streamer --input "​input_uvc.so \
 +                --device $device --fps $fps --resolution $resolution"​ \           
 +                --output "​output_http.so --www $www --port $port"
 +</​code>​
 +          ​
 +by (on a single line )
 +
 +<​code>​
 +service_start /​usr/​bin/​mjpg_streamer --input "​input_uvc.so --device $device --fps $fps --resolution $resolution"​ --output "​output_http.so --www $www --port $port"
 +</​code>​
 +
 +The command ''​mjpg_streamer -h''​ give you usage information and examples.
 +
 +If your webcam is an uvc supported by V4L but you cannot get an image (white page),
 +you may check that webcam output is not YUV only like output below:
 +
 +<​code>​
 +root@OpenWrt:​~#​ v4l2-ctl -V
 +Format Video Capture:
 +        Width/​Height ​ : 320/240
 +        Pixel Format ​ : '​YUYV'​
 +        Field         : None
 +        Bytes per Line: 640
 +        Size Image    : 153600
 +        Colorspace ​   : SRGB
 +</​code>​
 +
 +
 +The package ''​uvc-streamer''​ is no longer in the OpenWrt repositories.
 +  * https://​dev.openwrt.org/​browser/​packages/​multimedia/​uvc-streamer/​files/​uvc-streamer.init?​rev=10127
 +  * https://​dev.openwrt.org/​changeset/​17003/​packages/​multimedia/​uvc-streamer/​files/​uvc-streamer.init
 +
 +===== Link Dump =====
 +  * [[http://​wiki.leipzig.freifunk.net/​Diskussion:​Backfire#​quickcam_pro_5000]]
 +
 +
 +===== Tags =====
 +{{tag>​ip_camera video webcam}}