c++ opencv中unsigned char *、Mat、Qimage互相转换

发布时间:2023年12月20日

unsigned char * 转Mat

unsinged char * data =img.data;
Mat mat =(h,w,cv_8UC3,data,0);

void * 转Qimage

uchar * bit =(uchar*)pRknnInputData;
QImage image = QImage(bit, 2048,1536, QImage::Format_RGB888);

qimage转Mat

 QImage image =QImage (MODEL_INPUT_WIDTH_SIZE,MODEL_INPUT_HEIGHT_SIZE,QImage::Format_RGB32);
 Mat mat = Mat(image.height(), image.width(), CV_8UC4, image.bits(), image.bytesPerLine());

Mat转Qimage

cv::Mat image_bgr = cv::imread(“example.jpg”);
cv::Mat image_aligned;
cv::copyMakeBorder(image_bgr, image_aligned, 0, 0, 0, 0, cv::BORDER_DEFAULT);
QImage qimage(image_aligned.data, image_aligned.cols, image_rgb.rows, QImage::Format_BGR888);
文章来源:https://blog.csdn.net/qq_37797583/article/details/135112413
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。