本文主要是介绍c++ opencv中unsigned char *、Mat、Qimage互相转换,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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);
这篇关于c++ opencv中unsigned char *、Mat、Qimage互相转换的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!