dlib::array2d 与 cv::Mat 互转

dlib::array2d is an image already, you can use it for any dlib's image functions

load image:
dlib::array2d<dlib::rgb_pixel> img_rgb;
dlib::load_image(img_rgb, "test_image.jpg");

convert to greyscale:
dlib::array2d<unsigned char> img_gray;
dlib::assign_image(img_gray, img_rgb);

converto to OpenCV Image (cv::Mat):
#include <dlib/opencv.h>
#include <opencv2/opencv.hpp>
cv::Mat img = dlib::toMat(img_gray);

get image from OpenCV:
#include <dlib/opencv.h>
#include <opencv2/opencv.hpp>
cv::Mat img = cv::imread("test_image.jpg")
dlib::cv_image<rgb_pixel> dlib_img(img); // only stores pointer, no deep copy

Documentation is here. There are a lot of well-documented examples, you should start from them. Special example about array2d

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试