Difference between revisions of "Raspberry PI WebCam"

From BITPlan Wiki
Jump to navigation Jump to search
Line 1: Line 1:
* https://www.linux-projects.org/uv4l/installation/
+
{{:Self_Driving_RC_Car/Links}}
 +
 
 
= Webcam =
 
= Webcam =
 
<source lang='bash'  highlight="1-2">
 
<source lang='bash'  highlight="1-2">
Line 103: Line 104:
  
 
= Uv4l trial on Buster =
 
= Uv4l trial on Buster =
 +
* https://www.linux-projects.org/uv4l/installation/
 +
 
As of 2019-10-15 there is no official Buster support for uv4l yet see e.g.
 
As of 2019-10-15 there is no official Buster support for uv4l yet see e.g.
 
https://www.raspberrypi.org/forums/viewtopic.php?t=247305
 
https://www.raspberrypi.org/forums/viewtopic.php?t=247305

Revision as of 09:40, 22 January 2020

Click here to comment see Self Driving RC Car

Webcam

lsusb
Bus 001 Device 004: ID 046d:082c Logitech, Inc. HD Webcam C615

Software

qv4l2 Videograbbing

see https://wiki.ubuntuusers.de/Videograbbing/

sudo apt-get install qv4l2
qv4l2

Chesspic2019-10-15 1514.png

fswebcam

Installation

sudo apt-get install fswebcam

Script to take pictures (remotely)

#!/bin/bash
server=pichess
pic=chess$$.jpg
resolution=640x480
# https://raspberrypi.stackexchange.com/a/29284/11220 - skip some frames to adjust exposure
ssh $server fswebcam -r $resolution -S 10 -d /dev/video0 /tmp/$pic
scp $server:/tmp/$pic /tmp/$pic
open /tmp/$pic

Chess37846.jpg

motion

lsusb | grep cam
Bus 001 Device 005: ID 046d:0825 Logitech, Inc. Webcam C270
sudo apt-get install motion
v4l2-ctl -V
Format Video Capture:
	Width/Height      : 352/288
	Pixel Format      : 'MJPG' (Motion-JPEG)
	Field             : None
	Bytes per Line    : 0
	Size Image        : 102400
	Colorspace        : sRGB
	Transfer Function : Default (maps to sRGB)
	YCbCr/HSV Encoding: Default (maps to ITU-R 601)
	Quantization      : Default (maps to Full Range)
	Flags             : 
cd /etc/motion
git init
git add *
git commit -a -m "initial checkin"
# edit motion.conf with your favorite editor
 git diff motion.conf 
diff --git a/motion.conf b/motion.conf
index 23c8810..b96df83 100644
--- a/motion.conf
+++ b/motion.conf
@@ -8,7 +8,7 @@
 ############################################################
 
 # Start in daemon (background) mode and release terminal (default: off)
-daemon off
+daemon on
 
 # File to store the process ID, also called pid file. (default: not defined)
 process_id_file /var/run/motion/motion.pid
@@ -76,14 +76,14 @@ rotate 0
 flip_axis none
 
 # Image width (pixels). Valid range: Camera dependent, default: 320
-width 320
+width 352
 
 # Image height (pixels). Valid range: Camera dependent, default: 240
-height 240
+height 288
 
 # Maximum number of frames to be captured per second.
 # Valid range: 2-100. Default: 100 (almost no limit).
-framerate 2
+framerate 30
 
 # Minimum time in seconds between capturing picture frames from the camera.
 # Default: 0 = disabled - the capture rate is given by the camera framerate.
@@ -458,7 +458,7 @@ stream_motion off
 stream_maxrate 1
 
 # Restrict stream connections to localhost only (default: on)
-stream_localhost on
+stream_localhost off
 
 # Limits the number of images per connection (default: 0 = unlimited)
 # Number can be defined by multiplying actual stream rate by desired number of seconds
# fix /etc/default/motion
cat /etc/default/motion 
# set to 'yes' to enable the motion daemon
start_motion_daemon=yes

Uv4l trial on Buster

As of 2019-10-15 there is no official Buster support for uv4l yet see e.g. https://www.raspberrypi.org/forums/viewtopic.php?t=247305

As of 2020-01-21 there seems to be a work-around see https://blog.domski.pl/uv4l-on-raspberry-pi-running-debian-buster/

We will try using the commands for Raspberry Stretch

curl http://www.linux-projects.org/listing/uv4l_repo/lpkey.asc | sudo apt-key add -
echo "deb http://www.linux-projects.org/listing/uv4l_repo/raspbian/stretch stretch main" >>  /etc/apt/sources.list
sudo apt-get update
sudo apt-get install uv4l
# do we need to update the firmware?
# sudo rpi-update
sudo apt-get install uv4l-server uv4l-uvc uv4l-xscreen uv4l-mjpegstream uv4l-dummy uv4l-raspidisp
sudo apt-get install uv4l-webrtc

Check Webcam being identified

 dmesg | grep video
[    4.691736] videodev: Linux video capture interface: v2.00
[    4.838925] bcm2835-codec bcm2835-codec: Device registered as /dev/video10
[    4.844913] bcm2835-codec bcm2835-codec: Device registered as /dev/video11
[    4.852532] bcm2835-codec bcm2835-codec: Device registered as /dev/video12
[    4.989574] uvcvideo: Found UVC 1.00 device HD Webcam C615 (046d:082c)
[    5.028207] uvcvideo 1-1.2:1.2: Entity type for entity Extension 5 was not initialized!
[    5.028226] uvcvideo 1-1.2:1.2: Entity type for entity Processing 2 was not initialized!
[    5.028238] uvcvideo 1-1.2:1.2: Entity type for entity Camera 1 was not initialized!
[    5.028250] uvcvideo 1-1.2:1.2: Entity type for entity Extension 6 was not initialized!
[    5.028261] uvcvideo 1-1.2:1.2: Entity type for entity Extension 7 was not initialized!
[    5.028273] uvcvideo 1-1.2:1.2: Entity type for entity Extension 8 was not initialized!
[    5.028968] usbcore: registered new interface driver uvcvideo

U4v4l with OpenCV

Links