QString filename = QFileDialog::getOpenFileName(this,tr("open image"),"../",tr("Image File(*.png *.jpg *.jpeg *.bmp)")); if(filename == ""){
return;
}
cv::Mat image;
image = cv::imread(filename.toLatin1().data());//路径中不能有中文
cv::cvtColor(image,image,CV_BGR2RGB);
QImage img = QImage((const unsigned char *)(image.data),image.cols,image.rows,QImage::Format_RGB888);
ui->label->setPixmap(QPixmap::fromImage(img));
ui->label->resize(img.size());
ui->label->show();
【文件目录】OpenPic├── Camera_00.pro
├── Camera_00.pro.user
├── main.cpp
├── mainwindow.cpp
├── mainwindow.h
└── mainwindow.ui
0 directories, 6 files
评论