opencv Mat和Dlib变量类型转换
Mat转matrix<dlib::rgb_pixel> cv::Mat frame = cv::imread("test.jpg"); matrix<dlib::rgb_pixel> img; assign_image(img,cv_image<rgb_pixel>(frame)); array2d<dlib::bgr_pixel>转Mat 方法一: dlib::array2d<dlib::bgr_pixel> img_bgr;//使用dlib载入彩色的RGB图像 dlib::load_image(img_bgr, "test.jpg"); cv::Mat img = dlib::toMat(img_bgr); 方法二: cv::Mat temp_Roi; temp_Roi=imread("test.jpg"); array2d< bgr_pixel> img(temp_Roi.rows, temp_Roi.cols); for (int i = 0; i < temp_Roi.rows; i++) { for (int j = 0; j < temp_Roi.cols; j++) { img[i][j].blue = temp_Roi.at< cv::Vec3b>(i, j)[0]; img[i][j].green = temp_Roi.at< cv::Vec3b>(i, j)