PARP Research Group Universidad de Murcia

Interoperability with OpenCV

To enable the QVision to interoperate with OpenCV, the following line must be present (and un-commented) at the config.pri file, prior to compilation and installation of the QVision library:

CONFIG += qvopencv

QVision applications will automatically link to the include and binary files for the OpenCV library.

Converting QVision objects from and to OpenCV types

The QVision includes functionality to convert QVMatrix and QVImage objects from and to CvMat and IplImage types, making straightforward to include OpenCV code in a QVision application. To convert a QVMatrix object from and to an OpenCV's CvMat structure the developer can use the QVMatrix constructor and conversion operator:

// First create an OpenCv double precission matrix 
CvMat *cvMat = cvCreateMat(rows, cols, CV_64F);

// Next, init the contents of the OpenCV matrix.

// Converts the OpenCV matrix to a QVision matrix
QVMatrix qvMatrix = cvMat;

// Do things with the QVision matrix

// Converts the QVision matrix to a new OpenCV matrix
CvMat *cvMat2 = qvMatrix;       

// Do things with the new OpenCV matrix

// Delete OpenCV matrices
By now, only OpenCV matrices of double precision can be converted from and to QVMatrix objects.

Similarly, the developer can use QVImage constructor and conversion operators to convert from and to the OpenCV image format (IplImage):

// First create an OpenCV image object.
IplImage *iplImage = cvCreateImageHeader(cvSize(cols, rows), IPL_DEPTH_8U, 1);

// Next, init the contents of the OpenCV image.

// Create a new QVImage object from the 'iplImage' object.
// Both image objects, 'iplImage' and 'qvImage' will contain the same image.
QVImage<uChar, 1> qvImage = iplImage;

// Do things with the QVision image

// Create a new OpenCV image object, that will contain the same image as the 'qvImage' object.
IplImage *iplImageBis = qvImage;

// Do things with the new OpenCV image

// Finally, release the OpenCV images

OpenCV example applications

The examples/OpenCV directory includes some QVision application which use OpenCV functionality.

You can find a list in the module OpenCV interoperability example programs..

QVision framework. PARP research group. Copyright © 2007, 2008, 2009, 2010, 2011.