src/mex_pb_parts_final_selected.cpp
/*
 * Convert a 2D matrix to an mxArray.
 */
Convert a 2D matrix to an mxArray.
Convert a 2D matrix to an mxArray .
Mat* to_openCVMat(const matrix<>& m) {
    unsigned long mrows = m.size(0);
    unsigned long ncols = m.size(1);
    Mat* a = new Mat(static_cast<int>(mrows), static_cast<int>(ncols), CV_64FC1);
    double* data = (double*) a->data;
    for (unsigned long r = 0; r < mrows; r++) {
        for (unsigned long c = 0; c < ncols; c++) {
          data[(r * ncols) + c] = m(r, c);
        }
    }
    return a;
}
Mat * to_openCVMat ( const matrix < > & m ) { unsigned long mrows = m . size ( 0 ) ; unsigned long ncols = m . size ( 1 ) ; Mat * a = new Mat ( static_cast < int > ( mrows ) , static_cast < int > ( ncols ) , CV_64FC1 ) ; double * data = ( double * ) a -> data ; for ( unsigned long r = 0 ; r < mrows ; r ++ ) { for ( unsigned long c = 0 ; c < ncols ; c ++ ) { data [ ( r * ncols ) + c ] = m ( r , c ) ; } } return a ; }
Convert a 2D matrix to an mxArray.
Convert a 2D matrix to an mxArray .
/// TODO: check if CV_64FC1 means double // double *data = NULL; // data = (double*) (a->ptr<double>(r));    /// TODO: check if I need to use ptr<double> // data[c] = m(r,c);