This document discusses implementing parallel OpenCV applications on the Raspberry Pi 3. It describes using the Raspberry Pi 3 hardware platform and OpenCV with Java software. Approaches for parallelizing image processing algorithms in Java like the ForkJoinPool are presented. Live demos of algorithms like blue scaling and light intensity detection using parallelization are shown. Lessons learned around problems faced and references are also provided.
Implementing a parallel_open_cv_application_on_raspberry_pi3(1)
1. Meghadoot Gardi Rohith Raju
09.02.2017 ESM DPS WS 2016/2017 1
Implementing a parallel OpenCV
application on Raspberry Pi 3
2. Agenda
• Project Statement
• Platforms used for implementation
• Raspberry Pi 3
• OPENCV(3.1.0)with JAVA
• What is parallelism and What were parallel image processing approaches for the
problem statement
• Which were software platforms for coding, which we have chosen and why
• Approaches for parallelization in JAVA Eg. Fork join , stream etc. (why ForkJoinPool)
• Live demo: Blue scaler and Intensity Detection (Filter Operation)
• Lessons learnt: (Including Problems which we have faced)
• References
09.02.2017 ESM DPS WS 2016/2017 2Meghadoot Gardi
3. What?
09.02.2017 ESM DPS WS 2016/2017 3
Hardware Parallelism Real Time Computer Vision
Rohith Raju
5. Hardware Platform
Raspberry Pi-3 B
• It Is a single board and credit card
size personal computer.
• Build by Raspberry Pi Foundation in
the United Kingdom
• Intention to promote computer
science teaching
• Application :Home automation,
Embedded Prototyping
09.02.2017 ESM DPS WS 2016/2017 5
Meghadoot Gardi
6. Hardware Platform
Raspberry Pi-3 B
• RPI 3: 1.2GHz
• 64-bit quad-core
ARMv8 CPU
• 1GB RAM
• 802.11n Wireless LAN
• Camera interface
(CSI)
• Micro SD card slot
09.02.2017 ESM DPS WS 2016/2017 6Meghadoot Gardi
7. Models and Features
Type Model A Model B Zero
genera
tion
1 1+ 1 1+ 2 2 ver
1.2
3 Ver 1.2 Ver 1.3
Releas
e
02/12 11/14 05/12 07/14 02/15 10/16 02/16 10/15 05/16
Price
(US$)
25 20 35 25 35 5 US$
CPU 700 MHz, single 900 MHz, quad 1.2
GHz,
quad
1 GHz, single
32 bits 64 bits 32 bits
RAM 256MB 512 MB 1 GB 512 MB
USB 1 2 4 1 micro
mA 300 200 700 600 800 ~160 Meghadoot Gardi
8. • Most used:
• Raspbian, Raspbian Lite
• Ubuntu MATE
• Snappy Ubuntu Core(Third party)
• Windows 10 loT core(Third party)
• RISC OS
• Why Raspbian:
• Widely Used
• User Friendly(programming friendly)
os
Meghadoot Gardi
9. Raspberry Pi basic configuration
• Download OS on
Desktop or system.
• Format memory card
• Load OS image in the
memory card
• Create an empty SSH
folder in BOOT partition
• Insert memory card into
RPI and connect the
module to Wi-Fi router
via LAN cable (the DHCP
allows assigning dynamic
IP to RPI)
• Access the raspberry pi
via putty or MSYS2
Meghadoot Gardi
10. Raspberry Pi basic configuration
• Expand file system:
• sudo raspi-config Expand Filesystem
• sudo reboot
• Update OS to the latest version
• sudo apt-get update (updates the list of available packages and
their versions, but doesn’t install them)
• sudo apt-get upgrade (installs newer versions of the packages)
• sudo reboot
Meghadoot Gardi
12. Enabling Desktop Environment
• VNC Server will then start automatically whenever your Raspberry Pi is
powered on.
• To enable, VNC Server at the command line:
• Pass command : sudo raspi-config
• Navigate to Interfacing Options
• Scroll down and select VNC > Yes.
• Sudo reboot
Meghadoot Gardi
13. Enabling Camera Interface
• sudo modprobe bcm2825-v412
To automatically detect camera hardware.
• sudo raspistill -o xyz.jpg
Command to capture image
Meghadoot Gardi
14. OpenCV
09.02.2017 ESM DPS WS 2016/2017 14Rohith Raju
• OpenCV (Open Source ComputerVision Library)
• Developed by Intel, and now supported by Willow Garage and Itseez.
• It is free for use under the open source BSD license.
• The library is cross-platform.
• It focuses mainly on real-time image processing.
• Performance
• around 30 frames processed per seconds in real time image
processing (OpenCV)
• Implementations
Facial recognition system, Gesture recognition,
Human–computer interaction , Mobile robotics,
Motion tracking, Augmented reality
15. OpenCV
09.02.2017 ESM DPS WS 2016/2017 15Rohith Raju
OpenCV 3.1 Java Libraries features
Image Container
Blue
-Green-
Red
General Image
Processing Functions
Segmentation Camera Caliberation,
Stereo, 3D
Machine Learning
Detection
Recognition
Tracking Fitting
19. Concept Join Fork
09.02.2017 ESM DPS WS 2016/2017 19Rohith Raju
Main Class Fork and Join Class
Object ->
java.util.concurrent.ForkJoinPool
with number of processors used as
arguments.
Object of Fork and Join Class ->
java.util.concurrent.RecursiveAction
Begin Parallel processing ->
extends -> RecursiveAction
Default Method -> Compute
if-> Recursive Calls
else-> Intended Algorithm
20. Algorithm Implementation
09.02.2017 ESM DPS WS 2016/2017 20
Capture Image
• Load to Pi
• Stream From
Camera
Processing
• Load to Java
• Real Time
Processing
Serial
Processing
• OpenCV Libraries
Hardware
Parallelism
• Java Parallelism
• Task Division
Algorithm
Implementation
• OpenCV Libraries
Output
Comparison
• Parallel processing
• Serial processing
Rohith Raju
22. Implementation Of Blue Scaler
(Using Join Fork)
09.02.2017 ESM DPS WS 2016/2017 22Rohith Raju
BLUESCALER
23. Identification of Light Intensity
(Using Sobel Operator)
• Concept
• Application
• How Parallelization is achieved?
• Step By Step Overview
• Live Demo
09.02.2017 ESM DPS WS 2016/2017 23Meghadoot Gardi
24. Concept
• Sobel to calculate the derivatives from an image.
• This Derivative mask is also used as an Gradient. Sobel operator is used to
detect two kinds of edges in an image: Vertical direction edges and
Horizontal direction edges.
• This principle can be deployed in Identification of the “Intensity distribution
of Light Source”.
09.02.2017 ESM DPS WS 2016/2017 24Meghadoot Gardi
25. Concept
• A good way to express Pixel
intensity changes is by using derivatives
• A high change in gradient indicates a major
change in the image
• The intensity change in the vicinity of source
is shown by the “jump” in intensity in the
plot
• The edge “jump” can be seen more easily if
we take the first derivative
09.02.2017 ESM DPS WS 2016/2017 25Meghadoot Gardi
26. Insights of Output
(with only sunlight and with Lamp )
09.02.2017 ESM DPS WS 2016/2017 26Meghadoot Gardi
27. Algorithm Implementation
09.02.2017 ESM DPS WS 2016/2017 27
IDENTIFICATION OF INTENSIY OF SOURCE
B G R
Gray=B+G+R
Gray
Vertical
derivative
Horizontal
derivative
Gradient
Approximation
(RMS)
Steps to be followed:
Gray Scale Conversion
Gaussian Blur Implementation (In case of HD Images)
Sobel Filtering of Image
Meghadoot Gardi
28. Parallelization of algorithm
• Join-Fork Pool Implementation in
JAVA
• Fork for Gray Scale Implementation
• Join to get Gray Scale image
• Fork for Sobel implementation
• Join to get Intensity detailed Image
30. Conclusion
• What we have learnt:
• Image Processing using OpenCV Libraries
• Various Image Processing Algorithms and Filters
• Parallelization of Image Processing Algorithms (Some Exceptions Eg. Face Detection, Canny Edge
Detection)
• Problems Faced during Implementation:
• Interfacing issues with the Raspberry-Pi and Camera
• Installation and Compilation of OpenCV on Pi
• Installing JDK
• Version Change in OpenCV
09.02.2017 ESM DPS WS 2016/2017 30
It’s a high computing device.Small sized,compact and portable personal computer.Designed and developed by RP foundation in UK.To encourage embedded prototyping.
So this gave an idea of how we can access the RPbut it is headless!!No screen and keyboardHence, It is necessary to get access with remote login.
modprobe is a Linux program originally written by Rusty Russell and used to add a loadable kernel module (LKM) to the Linux kernel or to remove a LKM from the kernel. It is commonly used indirectly: udev relies upon modprobe to load drivers for automatically detected hardware.
OpenCV (Open Source Computer Vision) is a library of programming functions mainly aimed at real-time computer vision.[2]Originally developed by Intel's research center in Nizhny Novgorod (Russia), it was later supported by Willow Garage and is now maintained by Itseez.[1] The library is cross-platform and free for use under the open-source BSD license.
OpenCV (Open Source Computer Vision) is a library of programming functions mainly aimed at real-time computer vision.[2]Originally developed by Intel's research center in Nizhny Novgorod (Russia), it was later supported by Willow Garage and is now maintained by Itseez.[1] The library is cross-platform and free for use under the open-source BSD license.
CUDA is a parallel computing platform and application programming interface (API) model created by Nvidia.[1] It allows software developers and software engineers to use a CUDA-enabled graphics processing unit (GPU) for general purpose processing – an approach termed GPGPU (General-Purpose computing on Graphics Processing Units). The CUDA platform is a software layer that gives direct access to the GPU's virtual instruction set and parallel computational elements, for the execution of compute kernels.[2]
Which will split the image until it matches the task size.