Qtcreator opencv 显示图片
利用cvLoadImage()加载图片
void MainWindow::openPicture(QString path){
IplImage *pImg;
pImg = cvLoadImage(path.toLatin1(), 4);
cvNamedWindow("Image",1);
cvShowImage("Image",pImg);
cvWaitKey(0);
cvDestroyWindow("Image");
cvReleaseImage(&pImg);
}
openPicture("/home/sxy/qtproject/0807/opencv/images/rainbow.jpeg");
- 展示图片效果
利用imread()加载图片
void MainWindow::openAndCopyPicture(){
Mat myMat= imread("/home/sxy/qtproject/0807/opencv/images/rainbow.jpeg",0);
namedWindow("window",WINDOW_NORMAL);
imshow("window",myMat);
imwrite("copy.jpeg",myMat);
printPictureInfo(myMat);
}
openAndCopyPicture();
- 图片显示效果
图片参数显示
void MainWindow::printPictureInfo(Mat &mat){
qDebug()<<"col:"<<mat.cols<<"rows"<<mat.rows;
qDebug()<<"data:"<<mat.data;
}