Yes, this is the truth. Our task at hand is real-time acquisition of images from a USB webcam (Logitech C905), processing these images to identify a rectangle or a trapezium and then counting the number of filled and hollow circles inside and decoding this sequence of circles which stands for a particular coordinate in a big area.

We are using OpenCV for the computer vision part. OpenCV has a built-in facility for acquiring images directly from a webcam (external as well as integrated as in the case of a laptop). Things were working smoothly during the development stage – acquisition of images, processing, JPEG compression etc.

The problem surfaced when we ported the code to BeagleBoard-xM. We began to observe ghastly errors: premature end of JPEG data, extraneous bytes before markers, bad Huffman code etc. After plenty of research online, we were able to point at the hardware limitation of BeagleBoard-xM for the same. It is not able to complete one JPEG compression before starting to process the OpenCV code. The result is that while reading the image file, another write is going on. This results in data corruption as is indicated by the chopped-off and grayed images.

But, there is a work-around for this (it did not work for us, but plenty of people have been able to implement it). You can re-install OpenCV with JPEG support off. (Check this out!) This is done by adding the following code to your cmake statement:


DWITH_JPEG=OFF

What this will do is it will remove OpenCV’s ability to do anything related to JPEGs – read, write, open etc. So, by default, the format of reading data from the webcam changes from MJPG (Motion JPG) to YUYV which is not as sapping as the former. People have been able to do away with the errors mentioned above by implementing this work-around.

Another corollary to this – removing the JPEG support for the entire OS! Just un-install the effing libjpeg62-dev and all other corresponding libraries. We tried this and ended up losing the desktop of our Ubuntu Natty for OMAP. Re-installing the desktop was not possible as there was no resource available. Avoid the fiasco! Never un-install a system library. Ever!

Advertisements