Frank_GIS
Frank_GIS
采纳率25%
2015-04-19 06:48 阅读 2.1k

OPENCV中的cvmGet和cvmSet就真的没法用来处理8UC1的数据吗?

有什么好的解决办法么?曾经仿照cvmGet写过,可是在处理行列数较大的矩阵时就会出错,还找不到错误原因
不懂原理乱写的。。。
unsigned readmat( const CvMat* mat, int row, int col )
{
int type;

type = CV_MAT_TYPE(mat->type);
assert( (unsigned)row < (unsigned)mat->rows &&
        (unsigned)col < (unsigned)mat->cols );

if( type == CV_32FC1 )
    return ((float*)(mat->data.ptr + (size_t)mat->step*row))[col];
else if(type == CV_64FC1 )
{
    assert( type == CV_64FC1 );
    return ((double*)(mat->data.ptr + (size_t)mat->step*row))[col];
}
else
{
    return (((unsigned*)(mat->data.ptr + (size_t)mat->step*row))[col]);
}

}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

相关推荐