opencv,cv :: Mat to unsigned short *?

时间:2017-10-10 14:13:09

标签: c++ opencv

我有一个深度图像,用opencv加载到cv :: Mat。

我需要的是将数据作为unsigned short * depth

传递给函数

我这样做:

std::string frame1 = "rgbd_dataset_freiburg1_desk/depth/1305031453";
Mat img1;
img1 = imread(frame1, 0);


cv::Mat mat_ushort1;
frame1.convertTo(mat_ushort1, CV_16UC1);

到目前为止(我假设),非常好。现在我想将数据传递给这个函数:

void initModel(unsigned short * depth)

但是当我这样做时:

initModel(mat_ushort1.ptr());

我明白了:

Error (active)      argument of type "uchar *" is incompatible with parameter of type "unsigned short *"

我在这里缺少什么?我能以这种方式传递Mat数据吗?

谢谢。

编辑:

我发现了这个:

unsigned short* dataMat1 = mat_ushort1.ptr<unsigned short>();

可行,但会得到与预期不同的结果(与使用pangolin加载图像相比,这是我想避免的)。

0 个答案:

没有答案
相关问题