src/mex_pb_parts_final_selected.cpp
/*
 * Convert an mxArray to a matrix.
 */
Convert an mxArray to a matrix.
Convert an mxArray to a matrix .
matrix<> ToMatrix(const Mat& a) {
    unsigned long mrows = static_cast<unsigned long>(a.rows);
    unsigned long ncols = static_cast<unsigned long>(a.cols);
    double* data = (double*) a.data;
    matrix<> m(mrows, ncols);
    for (unsigned long r = 0; r < mrows; r++) {
        for (unsigned long c = 0; c < ncols; c++) {
          m(r, c) = data[r * ncols + c];
        }
    }
    return m;
}
matrix < > ToMatrix ( const Mat & a ) { unsigned long mrows = static_cast < unsigned long > ( a . rows ) ; unsigned long ncols = static_cast < unsigned long > ( a . cols ) ; double * data = ( double * ) a . data ; matrix < > m ( mrows , ncols ) ; for ( unsigned long r = 0 ; r < mrows ; r ++ ) { for ( unsigned long c = 0 ; c < ncols ; c ++ ) { m ( r , c ) = data [ r * ncols + c ] ; } } return m ; }
Convert an mxArray to a matrix.
Convert an mxArray to a matrix .
// double *data = NULL; // data = (double*) (a.ptr<double>(r));   /// TODO: check template for double // m(r,c) = data[c];