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,开发语言)