Friday 15 March 2013

What is the best way to use the OpenCV library in conjunction with the Armadillo library? -


I am creating an image processing application using OpenCV. I am also using the Armadillo library because there is something in it There are very accurate matrix related functions. However, to use Armadillo functions on CR :: MET to convert CV :: Mat to Arm :: Met by using CV :: MET to convert ARM :: mat Using a function such as

  arma :: Mat cvMat2armaMat (cv :: Mat M) {copy cv :: Mat data :   

Is there a more efficient way to do this?

To avoid or reduce the copy, you can use the Armandillo matrix through the member function Can access the memory. For example:

  mat x (5,6); Double * Mem = XM.Tr ();   

Be careful while using the above, because you are not allowed to free yourself (Armadillo will still manage the memory).

Alternatively, you get an Armadillo matrix from the current memory for example:

  double * data = new double [4 * 5]; // ... Fill data ... mat X (data, 4, 5, wrong); // 'wrong' indicates that no copies have to be made; View Doc   

In this case you will be responsible for managing the memory manually.

Also keep in mind that Armadillo stores and accesses the matrix, i.e. column 0 is stored first, then column 1, column2, etc. It is similar to that used by MATLAB, LAPACK and BLAS.

No comments:

Post a Comment