c++ - 如何将 cv::Mat 转换为 dlib::array2d, 和 typedef unsigned short int uint16_t
问题描述
我想在算法中使用用 realsensed435i 捕获的深度帧数据。而且,我需要获取 type 中的数据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 ..
and时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<dlib::bgr_pixel>(settings.inputMat));
这有效,但结果不正确。
那么,你有什么有效的技巧吗?
解决方案
dlib::assign_image(node.im, dlib::cv_image<ushort>(settings.inputMat));
成功!
推荐阅读
- javascript - 限制哑组件中的反应事件处理程序
- flutter - Flutter 流构建器概念
- integration-testing - 谓词值可以在 Mountebank 中使用通配符吗?
- svg - SVG 将颜色与整个背景混合
- javascript - Node.js 同步读取文件作为字符串(不是缓冲区)
- reactjs - Reactjs 视频播放器中的用户界面错误
- angular - 从 Angular 2 升级到 Angular 7,无法绑定 [x],因为它不是 [y] 的属性
- python - scipy curve_fit 不会改变初始猜测的参数
- javascript - 要求字符串输入时刻为某种格式
- android - Android Studio 无法找到 ADB,但我可以部署到我的设备