![]() |
University of Murcia, Spain ![]() |
InteroperabilityIn this section we describe how to use in a QVision application functionality from other top performance libraries and programming tools such as the OpenCV.OpenCVTo enable QVision functionality 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 += opencv The compilation of QVision applications will automatically link to the include and binary files for the OpenCV library. Also the QVision will include functionality to convert QVMatrix and QVImage objects from and to CvMat and IplImage types, which are the data type for matrices and images in the OpenCV library respectively. To convert a QVMatrix object from and to an OpenCV's CvMat structure the developer can use the QVMatrix constructor and conversion operator:
// Only double matrices can be converted from and to QVMatrix objects CvMat *cvMat = cvCreateMat(rows, cols, CV_64F); [...] QVMatrix qvMatrix = cvMat; // Converts from OpenCV matrix to QVision matrix [...] CvMat *cvMat2 = qvMatrix; // Converts from QVision matrix to OpenCV matrix [...] cvReleaseMat(&cvMat); // Deletes OpenCV matrices cvReleaseMat(&cvMat2); Similarly the developer can use QVImage constructor and conversion operator to convert from and to the OpenCV image format (IplImage):
IplImage *iplImage = cvCreateImageHeader(cvSize(getCols(), getRows()), IPL_DEPTH_8U, C); cvCreateImageData(iplImage); [...] QVImage<uChar, QVMatrix qvMatrix = cvMat; // Converts from OpenCV matrix to QVision matrix [...] CvMat *cvMat2 = qvMatrix; // Converts from QVision matrix to OpenCV matrix [...] cvReleaseMat(&cvMat); // Deletes OpenCV matrices cvReleaseMat(&cvMat2); The examples/OpenCV directory includes some QVision application which use OpenCV functionality. |