# 1) Install the Motion tool
sudo apt-get install motion -y
# 2) Check if a usb camera can be detected
lsusb
# 3) Display all connected videodevices/cameras
ls /dev/video*
lsmod | grep uvc
sudo modprobe uvcvideo
sudo modprobe /dev/video0
v4l2-ctl --all
# 4) Check cameral details
v4l2-ctl -V
'''
Format Video Capture:
Width/Height : 640/480
Pixel Format : 'YUYV'
Field : None
Bytes per Line: 1280
Size Image : 614400
Colorspace : SRGB
Flags :
'''
# 5) Edit Motion’s configuration file
sudo nano /etc/motion/motion.conf
# 6) Enable motion service
/etc/init.d/motion stop && fswebcam && /etc/init.d/motion start
'''
[....] Stopping motion (via systemctl): motion.service==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to stop 'motion.service'.
Multiple identities can be used for authentication:
1. ,,, (pi)
2. root
Choose identity to authenticate as (1-2): 1
Password:
==== AUTHENTICATION COMPLETE ===
. ok
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
No input was specified, using the first.
Adjusting resolution from 384x288 to 352x288.
--- Capturing frame...
Captured frame in 0.00 seconds.
--- Processing captured image...
There are unsaved changes to the image.
[....] Starting motion (via systemctl): motion.service==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to start 'motion.service'.
Multiple identities can be used for authentication:
1. ,,, (pi)
2. root
Choose identity to authenticate as (1-2): 1
Password:
==== AUTHENTICATION COMPLETE ===
. ok
'''
# 7) Start motion service
sudo service motion start
sudo service motion stop
sudo service motion status
# 8) Play the video
omxplayer /home/pi/Monitor/01-20190419104218.avi