Saturday, April 27, 2013

The mystery of OpenCv and BeagleBoard-XM

This guide is for anyone who is thinking of using BeagleBoard-xM DM3730's DSP for OpenCV to get an extra boost in algorithm execution. This guide is also for everyone who has just started to search for leads , hints, pointers... anything regarding OpenCV and BB-xM

I'll start by referring to a Texas Instruments White paper on OpenCV on TI’s DSP+ARM platforms. The white paper suggests that OpenCV can and is easily ported on TI's heterogeneous SoC (ARM+DSP).

This white paper lead me to believe that we have a shot at porting our current OpenCV anaytics app to an embedded platform assuming it to be a simple "Cross-compile" with the hurdles of "any other" cross-compilation exercise, but I was wrong.

Where was I wrong , you ask ?

1 - Beagleboard-xM has (DM3730) ARM Cortex A8 + DSP (C64x). ARM Cortex A8 has neon fpu but DSP (C64x) is only a fixed point DSP. So, thinking that porting OpenCV to DM3730 will yield the results I wanted to see was wrong.
OpenCV heavily relies on floating point arithmetic, and absence of a hardware fpu may not give the boost I needed.

2 - TI's claim that OpenCV has been ported and optimized for TI's multicore systems. The OpenCV port is compiled with C6EZaccel library which has been rendered obsolete by TI but is still downloadable. And a guide is available for reference on how to Get started with C6EZaccel. But C6EZaccel v2.xxx is the one with "so called" optimized port of OpenCV and that is only available for DM8148 and DM8168.

3 - TI's support will almost always point to Building OpenCV for ARM Cortex A-8 .

4 - C6EZaccel is obsolete, and hence proper support is no longer there. TI is promoting its VLIB I guess. Which leads me to believe that OpenCV project didn't go very well.

Conclusion:
BB-xM is a very good embedded hardware to start a project on. It can make use of OpenCV easily but only on ARM following the guide mentioned in pt.3 .But BB-xM is not a good choice if you are expecting a boost in performance by porting OpenCV to its DSP side.

Useful pointers:
OpenCV is a floating point depended library.
C64x is a fixed point DSP.
C674x is a floating point DSP
If you want performance in OpenCV, use IPP.


I hope this post will save a lot of days of internet surfing for many.

2 comments:

  1. Hello Muhammad Ali,

    I wanted to know if beagleboard supports C++ interfaces too ? This is because in the OpenCV tutorial documentation 2.4.6.0 , it is said that "the main downside of the C++ interface is that many embedded development systems at the moment
    support only C."

    Avinash

    ReplyDelete
    Replies
    1. it depends on the Toolchain you are using to compile the code for BB. I recommend ARM toolchain by code sourcery. it supports C++ too.

      Delete