This project describes a technique to capture human faces using image processing and turn on an LED on the Arduino board. With some modification it can be used to detect intruders and set an alarm.
Embedded system components
Five basic components required to build an embedded system using Python are described below briefly.
Operating system (OS). The OS is the heart of an embedded vision system. Many dependencies that are required to run software are provided by the OS, which is the interface between the hardware and the application software. There are various Linux distributions, such as Ubuntu and Fedora, to choose from. I prefer Ubuntu as it is easy to learn.
Image processing (IP) software. There are many software and libraries available for image processing, such as MATLAB and OpenCV. I prefer OpenCV as it is free, fast, has good documentation, tutorials, user groups, forums, etc. There are a lot of pre-built functions and algorithms to get a head start. There is active development on interfaces for other languages like Ruby, Python, MATLAB, etc. Fig. 1 is a block diagram showing the different modules in OpenCV.
Arduino. To control peripheral devices, we need a hardware circuit with a ‘brain.’ This role can be played by any microcontroller or microprocessor. A microcontroller cannot be directly used in a circuit as it is. A full development circuit board has to be made, providing access to different pins of the microcontroller. Here, Arduino development board is used due to the following reasons:
1. It is open source, so all schematics are available and you can design the same board on your own.
2. It is based on the concept of breadboard prototyping, which encourages the use of hook-up wires and breadboard, to make a circuit which can be easily modified later. This avoids the hassle of soldering.
3. There are a number of tutorials, tons of code, forums, etc, to help beginners.
4. The design of the board and IDE is so simple that one does not have to be an engineer to use it.
5. It is pretty cheap compared to other available development boards.
There are various versions of Arduino to choose from, such as Uno, Mega and Lilypad. I prefer the Arduino Mega, which is a microcontroller board based on the ATmega1280. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable, or power it with an AC-to-DC adaptor or battery, to get started.
Pyserial. This is a library that provides Python support for serial connections (RS232) over a variety of different devices: serial COM ports, Bluetooth dongles, infra-red ports, and so on. It also supports remote serial ports via RFC 2217 (since v2.5). We use this for communication with the external hardware (Arduino). This library is easy to use and it has good documentation.
Python. Python is a general-purpose, high-level programming language whose design philosophy emphasises code readability. Python claims to combine remarkable power with very clear syntax, and its standard library is large and comprehensive.
Let us now proceed to OpenCV installation. All commands are meant to be run in a terminal.
1. Install all pre-requisites as shown below:
2. Install Python development headers with ‘sudo apt-get install python-dev.’