本文介绍了如何将mat转换为array2d< rgb_pixel>?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为面部标志性代码创建了dll,使用array2d来获取图像,但是我喜欢使用Mat读取图像并转换为array2d,因为dlib仅支持array2d。任何人都可以说如何将mat转换为array2d?

I created dll for the dlib face landmark code there used array2d to get the image, but i like to read an image using Mat and to convert to array2d because dlib supports only array2d. Can any one say how to convert mat to array2d ??

推荐答案

转换 cv :: Mat 图像到 dlib :: array2d

如果是BGR图像,您可以按照以下步骤操作:

In case of a BGR image, you can follow this:

dlib::array2d<bgr_pixel> dlibImage;
dlib::assign_image(dlibImage, dlib::cv_image<bgr_pixel>(cvMatImage));

并且,如果您有灰度图像,只需使用< unsigned char> ; 而不是< bgr_pixel>

And, if you have a grayscale image, simply use <unsigned char> instead of <bgr_pixel>:

dlib::array2d<unsigned char> dlibImageGray;
dlib::assign_image(dlibImage, dlib::cv_image<unsigned char>(cvMatImageGray));

这篇关于如何将mat转换为array2d&lt; rgb_pixel&gt;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-17 06:06