PARP Research Group Universidad de Murcia


Interoperability with Octave

To enable the QVision to inter-operate with Octave, the following line must be not commented at the config.pri file, prior to compilation and installation of the QVision library:

CONFIG += qvoctave

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

Converting QVision objects from and to Octave library types

The QVision includes functionality to convert QVMatrix objects from and to Octave Matrix objects. To convert a QVMatrix objects from and to an Octave Matrix objects, the developer can use the QVMatrix constructor and conversion operators:

// First create an Octave matrix
Matrix octMatrix(rows, cols);

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

// Converts the Octave matrix to a QVision matrix
QVMatrix qvMatrix = octMatrix;

// Do things with the QVision matrix
[...]

// Convert back the QVision matrix to a new Octave matrix
Matrix octMatrix2 = qvMatrix;

Using QVMatrices with functions of the Octave library

You can generally use QVMatrix objects directly with Octave library functions and code. This is so because the QVMatrix class provides a constructor and a cast operator, to convert QVMatrix objects from and to Matrix objects, transparently to the programmer. The following code uses Octave library functionality to obtain the Hessenberg decomposition of a square 3x3 random matrix A:

QVMatrix A = QVMatrix::random(3,3);

HESS hessA(A);  // Hessenberg decomposition of matrix 'A'

const QVMatrix  H = hessA.hess_matrix(),
                P = hessA.unitary_hess_matrix();

When executing this code, matrices H and P should contain respectively the Hessenberg and the unitary Hessenberg matrices, from the Hessenberg decomposition of matrix A:

A = QVMatrix (3, 3)
[
    [ 0.215825 0.431953 0.226107 ]
    [ 0.920128 0.281059 0.276235 ]
    [ 0.881062 0.307458 0.416501 ]
]

H = QVMatrix (3, 3)
[
    [ 0.215825 -0.468366 -0.135431 ]
    [ -1.273933 0.637416 -0.064699 ]
    [ 0.000000 -0.095923 0.060145 ]
]

P = QVMatrix (3, 3)
[
    [ 1.000000 0.000000 0.000000 ]
    [ 0.000000 -0.722273 -0.691608 ]
    [ 0.000000 -0.691608 0.722273 ]
]

P*H*P' = QVMatrix (3, 3)
[
    [ 0.215825 0.431953 0.226107 ]
    [ 0.920128 0.281059 0.276235 ]
    [ 0.881062 0.307458 0.416501 ]
]

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

CONFIG += qvoctave

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

Converting QVision objects from and to Octave library types

The QVision includes functionality to convert QVMatrix objects from and to Octave Matrix objects. To convert a QVMatrix object from and to an Octave Matrix object, the developer can use the QVMatrix constructor and conversion operators:

// First create an Octave matrix
Matrix octMatrix(rows, cols);

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

// Converts the Octave matrix to a QVision matrix
QVMatrix qvMatrix = octMatrix;

// Do things with the QVision matrix
[...]

// Convert back the QVision matrix to a new Octave matrix
Matrix octMatrix2 = qvMatrix;

Using QVMatrices with functions of the Octave library

You can generally use QVMatrix objects directly with Octave library functions and code. This is so because the QVMatrix class provides a constructor and a cast operator, to convert QVMatrix objects from and to Matrix objects, transparently to the programmer. The following code uses Octave library functionality to obtain the Hessenberg decomposition of a square 3x3 random matrix A:

QVMatrix A = QVMatrix::random(3,3);

HESS hessA(A);  // Hessenberg decomposition of matrix 'A'

const QVMatrix  H = hessA.hess_matrix(),
                P = hessA.unitary_hess_matrix();

When executing this code, matrices H and P should contain respectively the Hessenberg and the unitary Hessenberg matrices, from the Hessenberg decomposition of matrix A:

A = QVMatrix (3, 3)
[
    [ 0.215825 0.431953 0.226107 ]
    [ 0.920128 0.281059 0.276235 ]
    [ 0.881062 0.307458 0.416501 ]
]

H = QVMatrix (3, 3)
[
    [ 0.215825 -0.468366 -0.135431 ]
    [ -1.273933 0.637416 -0.064699 ]
    [ 0.000000 -0.095923 0.060145 ]
]

P = QVMatrix (3, 3)
[
    [ 1.000000 0.000000 0.000000 ]
    [ 0.000000 -0.722273 -0.691608 ]
    [ 0.000000 -0.691608 0.722273 ]
]

P*H*P' = QVMatrix (3, 3)
[
    [ 0.215825 0.431953 0.226107 ]
    [ 0.920128 0.281059 0.276235 ]
    [ 0.881062 0.307458 0.416501 ]
]



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