AWS IoT Setup  |   AWS IoT Greengrass Setup  |   AWS Machine Learning Interface

AWS SDK Setup  |   AWS SDK Rekognition

GCP IoT Setup

GCP SDK Setup

Device: Camera Setup


0. Install a video player ‘omxplayer’

# Install omxplayer
sudo apt-get install omxplayer

# Key bindings
'''
 Increase Speed
2 Decrease Speed
j Previous Audio stream
k Next Audio stream
i Previous Chapter
o Next Chapter
n Previous Subtitle stream
m Next Subtitle stream
s Toggle subtitles
q Exit
Space or p Pause/Resume
– Decrease Volume
+ Increase Volume
Left Seek -30
Right Seek +30
Down Seek -600
Up Seek +600
'''

# Note: mplayer and VLC player did not work well


1. Set up a picamera for taking photos

# Set up
sudo apt-get update
sudo apt-get upgrade
sudo raspi-config
'''Use the cursor keys to move to the camera option, and select 'enable'. '''
sudo reboot

# Take a photo
cd Iot_EdgeComputing/src/device/picamera
raspistill -v -o cam.jpg


2. Set up a picamera for capturing videos

# Take a 10s video
cd Iot_EdgeComputing/src/device/picamera
raspivid -o pipi.h264 -t 10000

# Play the video
omxplayer pipi.h264

# mp4 format is also supported


3. Set up a usb web cam for taking photos

# 1) Install the fswebcam package
sudo apt-get install fswebcam

# 2) Add your user to video group
sudo usermod -a -G video pi

# 3) Basic usage to take a photo
fswebcam image.jpg

# 4) If you are using an old camera and get black images, skip the first 20 frames
fswebcam -S 20 image2.jpg


4. Set up a usb web cam for video streaming

# 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

References