-
Notifications
You must be signed in to change notification settings - Fork 2
OpenCV
OpenCV is a well known Open Source Vision Library. It's been designed to run on a Desktop. But with a few changes, a big amount of the functionality can be used under the leanXcam.
The official website is http://opencv.willowgarage.com. A good overview and documentation can be found on the page http://opencv.willowgarage.com/documentation/index.html.
This describes how to adapt the official OpenCV source code to make it run on the Blackfin DSP under uClinux. The version used here is 2.0.0 but it should also work with newer versions. On the Downloads page you find a package where these changes are already applied. So this section is only for users who need the newest or a special version of OpenCV. You are welcome to share if you transate a new version of OpenCV.
The Blackfin Toolchain doesn't support wide char, so we have to remove it.
In the file src/cxcore/cxpersistence.cpp you have to remove the line
#include <wchar.h>
and the functions fromUtf16
and toUtf16
.
In the file include/opencv/cxcore.hpp replace
typedef std::basic_string<wchar_t> WString;
with
typedef std::basic_string<char> WString;
and remove the lines
CV_EXPORTS string fromUtf16(const WString& str); CV_EXPORTS WString toUtf16(const string& str);
Now you should be able to configure and compile OpenCV.
Some functions have to be disabled for successful configuration since they are not supported. We configure OpenCV as a static library which is linked into the application. This increases the size of the resulting application at about 2.3 MB.
If you downloaded OpenCV from the Downloads page, you can execute the do-build
script with
$ ./do-build
This will configure and build the library for the target and for the host.
To do these steps manually, use the following commands:
- Configure and build it for the target:
$ ./configure --host=bfin-uclinux --without-octave --without-gtk --without-v4l --without-carbon \ --without-quicktime --without-1394libs --without-ffmpeg --without-python --without-swig --enable-static \ --disable-shared --disable-apps --disable-openmp LDFLAGS=-mfast-fp $ make
- Configure and build it for the host:
$ ./configure --without-octave --without-gtk --without-v4l --without-carbon --without-quicktime \ --without-1394libs --without-ffmpeg --without-python --without-swig --enable-static --disable-shared \ --disable-apps --disable-openmp $ make
The static library can be found in the folder src/.libs/.
The easiest way to use OpenCV is to use the Makefile and the configure script from the Web-View-Cpp application. Then the OpenCV library will automatically be linked. You only have to include the main OpenCV header with
#include <cv.h>
When configuring the application you have to use the g++ compiler to use OpenCV.
If you want to link it on your own, add the library path and these libraries to the linker options:
- host: -lcvaux -lcv -lcxcore -lpthread -ldl -lrt -lz
- target: -lbfdsp -lcvaux -lcv -lcxcore -lpthread -lrt