Saturday, December 31, 2016

OpenCV face detection on UDOO with Arch Linux

A few years ago, tried to run face detection on BBB.  This time trying it on the more powerful UDOO platform.  Some minor code changes:

- Move from Python module cv to cv2
- OpenCV 3.x

My UDOO is running Arch Linux with kernel 4.9.  Note that the libGL included in "imx-gpu-viv-fb" doesn't work properly with OpenCV.  Switching to "mesa-libgl" solved the issue.

$ sudo pacman -Sy mesa-libgl opencv python2-numpy

A Logitech C200 USB web camera is plugged in and detected automatically.

$ lsusb
Bus 001 Device 003: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
Bus 001 Device 004: ID 046d:0802 Logitech, Inc. Webcam C200
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

$ lsusb -s 001:004 -v | egrep "Width|Height"
Couldn't open device, some information will be missing
        wWidth                            640
        wHeight                           480
        wWidth                            160
        wHeight                           120
        wWidth                            176
        wHeight                           144
        wWidth                            320
        wHeight                           240

The camera supports maximum resolution of 640x480.  But reducing the capture to 320x240  (line 9-10) produces a smoother video on UDOO.

The refresh rate is approximately 30fps.  Change the waitKey parameter (line 58) to adjust it.

No comments: