This week I have taken delivery of a Raspberry Pi 2, and a Pi camera module: Total cost around UKP50. The aim of the experiment is to see whether the Pi is powerful enough to be used for computer vision applications in the real world. More of that over the coming days, but the short version is: Yes it is.
I also needed several other Pi-related components (again, more details of the fun we’re having at a later date). For various reasons mostly to do with who had what in stock, I split the purchases between two UK companies – 4Tronix, who supply all sorts of superb robotics stuff for Pi and Arduino, and The Pi Hut, who as the name implies sell all things Pi-related. Both orders were handled quickly, and I recommend both companies highly.
Setting up the new Pi took 2 minutes, and attaching the camera module is easy, if slightly fiddly.
I used the ‘picamera’ module and was getting images displayed on screen, and saved to the filesystem, all within a further few minutes. The ‘picamera’ module appears to be a very well written library, and the API is certainly powerful.
It was then time to build OpenCV. This is a slightly more involved process (build it from the source code), which took a few minutes of hands-on time, followed by about 4 hours of waiting for it to compile. A quick experiment then showed OpenCV working properly from both C++ and Python.
The picamera module can process images in such a way that they can be handled by OpenCV – the interface between the two is straightforward. As such, within a few more minutes I was grabbing images live from the Pi camera module, and processing them with normal OpenCV Python calls. I don’t yet know what would be involved in getting images from the camera from C++, but with a Python interface this good, it may not be necessary to worry about it (Python can of course call C/C++ routines anyway).
Initial impressions are that it all works beautifully. On the *initial* setup, it seems to take about one second to capture a frame from the camera, but the good news is that OpenCV processing (standard pre-processing such as blurring, and Canny edge detection) are faster than I’d expect from a computer this size. After playing with a few settings, I am now able to increase the frame rate to many frames per second at capture, and around 4 FPS even including some OpenCV work (colour conversion, blur, and Canny edge detection) – bearing in mind some of those are compute-intensive tasks, I think that’s impressive.
So yes: The Raspberry Pi 2 and the Pi camera module are certainly suitable for computer vision tasks using OpenCV, and I have two contracts lined up already to work on this.