In this tutorial we’ll see how to implement an OpenCV App with Python and an Arduino sketch that reads OpenCV data and moves a UDOO screen when you move your face in the UDOO camera range.
OpenCV is an open source computer vision and machine learning software library that makes possible to process images and to do face tracking, face detection, shape detection and other cool stuff. It has C, C++, Python and Java interfaces and supports Windows, Linux, Mac OS, iOS and Android. OpenCV is written in optimized C/C++, so that the library can take advantage of multi-core processing.
OpenCV library is pre-installed on UDOObuntu.
What we need is:
If you’ve met all the above requirements, let’s boot UDOObuntu! And let’s understand how the OpenCV library works and how the Sam3x Arduino controller is connected to IMX6, where UDOObuntu runs.
Remember that is necessary to enable the UDOO cam before doing something else; to enable it to take a look at the guide on this site.
In this simple project we used Python but you can also use Java or C/C++, just pay attention to import cv2 (as OpenCV library) in you project.
Remember that to use the serial port in Python you must import the serial library in the header of the script.
Before importing the serial library, you have to install it. To do this you have to open a terminal window and execute this instruction:
So let’s start and check the code together!
This is what you need to run the App:
Python file, for example webcam.py
So let’s start and check some code!
These are the needed components of the App:
Python file, for example webcam.py
And here you can check the Arduino sketch:
After this simple code, you have to download an xml file that describe a figure or an object: this xml file is the most used and accurate to detect face but actually is not very performant.
Here is a prototype:
Finally to run your python script you have to open a terminal window and write
In this case:
Here you can download the complete code of this example demo:
So, here’s the final result!
Comments