我想在算法中使用用realsensed435i捕获的深度帧数据。而且,我需要获取dlib::array2d<uint16_t>
类型的数据。但是我无法直接获取它,因此,我的方法是先获取cv::Mat
,然后再将其转换为dlib::array2d<uint16_t>
。
而且我尝试了下面的代码,但是它们不起作用!
case1: dlib::assign_image(node.im, dlib::cv_image<uint16_t> (settings.inputMat));
case2: dlib::assign_image(node.im, dlib::cv_image< unsigned char >(settings.inputMat));
当我运行
camke ..
和make
时,它成功。但是当我运行可执行二进制文件时,它会出错。case1:hewenhui@hewenhui-Inspiron-7590:~/pre_PSLAM/D-KHT-master/bin$ ./testlib
**************************** FATAL ERROR DETECTED ****************************
Error detected at line 36.
Error detected in file /usr/local/include/dlib/opencv/cv_image.h.
Error detected in function dlib::cv_image<pixel_type>::cv_image(const cv::Mat&) [with pixel_type = short unsigned int].
Failing expression was img.depth() == cv::DataType<typename pixel_traits<pixel_type>::basic_pixel_type>::depth && img.channels() == pixel_traits<pixel_type>::num.
The pixel type you gave doesn't match pixel used by the open cv Mat object.
img.depth(): 0
img.cv::DataType<typename pixel_traits<pixel_type>::basic_pixel_type>::depth: 2
img.channels(): 3
img.pixel_traits<pixel_type>::num: 1
******************************************************************************
已放弃 (核心已转储)
case2:
**************************** FATAL ERROR DETECTED ****************************
Error detected at line 36.
Error detected in file /usr/local/include/dlib/opencv/cv_image.h.
Error detected in function dlib::cv_image<pixel_type>::cv_image(const cv::Mat&) [with pixel_type = short unsigned int].
Failing expression was img.depth() == cv::DataType<typename pixel_traits<pixel_type>::basic_pixel_type>::depth && img.channels() == pixel_traits<pixel_type>::num.
The pixel type you gave doesn't match pixel used by the open cv Mat object.
img.depth(): 0
img.cv::DataType<typename pixel_traits<pixel_type>::basic_pixel_type>::depth: 2
img.channels(): 3
img.pixel_traits<pixel_type>::num: 1
******************************************************************************
已放弃 (核心已转储)
case3:dlib::assign_image(node.im,dlib::cv_image (settings.inputMat));
这可行,但结果不正确。
那么,您有什么有效的秘诀吗?
最佳答案
dlib::assign_image(node.im, dlib::cv_image<ushort>(settings.inputMat));
成功!