OpenCV中Mat 和 IplImage 到 Qt中的QImage
1. Mat 到 QImage
Mat frame;
VideoCaputre vid("your_fileName");//open video file
if(!vid.isOpened())//check if we succeeded
return -1;
vid >> frame;//extract a frame
或者
IplImage* srcIplImg = cvLoadImage("your_fileName", 1);
frame(srIplImg);
QImage* qImg = new QImage(frame.data, frame.cols, frame.rows, QImage::Format_RGB888);
2. IplImage 到 QImage
IplImage* srcIplImg = cvLoadImage("your_fileName", 1);
int w = srcIplImg->width;
int h = srcIplImg->height;
QImage* qImg = new QImage(QSize(w, h), QImage::Format_RGB888);
Iplmage* iplDstImg = cvCreateImageHeader(cvSize(w, h), 8, 3);
iplDstImg ->imageData = (char*)qImg->bits();
cvCopy(srcIplImg, iplDstImg , 0);
cvCvtColor(iplDstImg , iplDstImg , CV_BGR2RGB);