【opencv】Dlib图像格式与Opencv图像格式之间的转化

Mat转matrix

cv::Mat frame = cv::imread("123.jpg");

matrix img;
assign_image(img,cv_image(frame));

dlib转mat

dlib::array2d img_bgr;//使用dlib载入彩色的RGB图像      
dlib::load_image(img_bgr, "test_image.jpg");   
cv::Mat img = dlib::toMat(img_bgr);//这样图片不失真
cv::Mat img = dlib::toMat(img_gray);

Mat转dlib::cv_image

cv::Mat img = cv::imread("test_image.jpg")  
dlib::cv_image dlib_img(img); 

rect转dlib的rect

 dlib::rectangle dlibRect((long)opencvRect.tl().x, (long)opencvRect.tl().y, (long)opencvRect.br().x - 1, (long)opencvRect.br().y - 1);

 

你可能感兴趣的:(OPENCV)