我有一个应用程序,需要pangolin::Image
格式rgbd图像。我想发送一个cv::Mat
。如何将cv :: Mat转换为穿山甲::图像?将cv :: Mat转换为穿山甲::图片?
(穿山甲:https://github.com/stevenlovegrove/Pangolin)
图片标头:
https://github.com/stevenlovegrove/Pangolin/blob/master/include/pangolin/image/image.h
目前格式是:
pangolin::ManagedImage<unsigned short> firstData(640, 480);
pangolin::Image<unsigned short> firstRaw(firstData.w, firstData.h, firstData.pitch, (unsigned short*)firstData.ptr);
其中firstRaw
然后通过应用程序发送。
如果我现在有:
cv::Mat frame = cv::imread(filepath,0);
什么是frame
到firstRaw
转换?
我开始是这样的:
int loadDepthFromMat(cv::Mat filepath, pangolin::Image<unsigned short> & depth)
{
int width = filepath.cols;
int height = filepath.rows;
pangolin::ManagedImage<unsigned short> depthRaw(width, height);
pangolin::Image<unsigned short> depthRaw16((unsigned short*)depthRaw.ptr, depthRaw.w, depthRaw.h, depthRaw.w * sizeof(unsigned short));
//copy data
}
谢谢。
假设穿山甲::图像在主机/ cpu内存上,在确认穿山甲图像已被分配后,在数据指针上使用memcpy()。只要确保首先将OpenCV图像转换为无符号短格式。 –
感谢您的回复。如果你有时间,请给我一个例子吗? – anti