Table of Contents

Overview

Beside the commercial image processing libraries like Halcon currently developed at the munich software company MVTec Software GmbH there alternatively exists a very fast and optimised, noncommercial but highly portable open source imaging library called OpenCV (Open Computer Vision). Developed by Intel® in the late 1990 the library is still subjected to the Intel® terms of license - but still free for noncommercial, academic and commercial use.

The library is mainly aimed at real time computer vision providing developers with very fast and efficient algorithms state of the art in various fields of image processing. Exemplary topics are:

As mentioned before OpenCV is highly portable and therefore available for various operation systems (e.g. Microsoft Windows® and Linux) and a huge number of hardware platforms (for example x86_32, x86_64, arm, ppc, …). You will find further details on the documentation site of OpenCV. OpenCV also provides transparent interface to Intel® Integrated Performance Primitives (IPP). That is, it loads automatically IPP libraries optimized for a specific processor at runtime, if they are available.

The main components and modules of OpenCV are:

Procedure for installation under Linux

Getting OpenCV

Before building and installing OpenCV you will first have to download the relevant sources. You may follow this link to get the latest stable version.

Extracting the sources

When downloaded a stable version extract the source files in a directory (e.g. /tmp). The following command-sequence shows you how to proceed:

tar xvzf OpenCV-1.0.0.tar.gz

Build the binaries

After extracting the sources change into the newly created directory

cd opencv-1.0.0

We now compile and install OpenCV for native use on you host system.

./configure
make
make install

The last point is to create the cross binaries appropriate for your FESTO SBOx smartcamera. export CXXFLAGS=-DHAVE_LRINT

./configure --host=arm-linux --prefix=/opt/sbo/gcc332
make
make install

To be able to use OpenCV in your applications don't forget to transfer following shared object-libraries onto the FESTO SBOx smartcamera:

Using OpenCV and the eno-smartcamera

The short code-snippet below gives you a good point to start and to demonstrate the principles in combining OpenCV with user-defined applications.

#include <opencv/cv.h>
#include <opencv/cxcore.h>
#include "OCamera.h"
 
OCameraImage img;
IplImage *iplimg;
 
pCamera = OCamera::CreateCameraInterface(OCamera::CAM_TYPE_MT9V403);
pCamera->Open(640*480*4);
pCamera->SetCameraWindow(0, 0, 640, 480);
pCamera->SetShutterTime(2000); 
pCamera->SetGain(4); 
 
pCamera->SetAcquisitionMode(OCamera::ACQ_MODE_SINGLE_SHOT); 
pCamera->GetImage(&img);
pCamera->SetAcquisitionMode(OCamera::ACQ_MODE_STOP);
 
iplimg = cvCreateImageHeader(640*480, 8, 1);
cvSetData(iplimg, img.pData, 640*480);

To (cross)compile your programs you will need to type in following commands for example (1st compile the
files and 2nd activate the linker). arm-linux-gcc -c myfirst_opencvapp.c

arm-linux-gcc -o myfirst_opencvapp -L/opt/sbo/gcc332/lib -lcv -lcxcore -lcvaux -lhighgui