0

有没有办法将图像作为名称而不是 QT(C++) 中 Qpixmap 的路径传递,例如,我有以下代码,其中应使用 Qpixmap 标签显示处理后的图像,但是当我尝试时,我必须保存它,然后将其传递给 Qpixmap 进行显示,,但这不是一种有效的方式,所以任何人都可以帮助我,请我是 Qt 的新手并且没有经验..

    void MainWindow::on_pushButton_3_clicked()
{
    cv::Mat hsv_img, seg_img,infected_area, hsv_infected,seg_input,hsv_seg;
    Mat filter_img,hsv;

    cv::Mat input_image = imread(this->file_name.toAscii().data());
    medianBlur(input_image,filter_img,7);
    cvtColor(filter_img, hsv, CV_BGR2HSV);
    hsvSeg(filter_img,hsv, hsv_img, seg_img,14.0,0.0,117.0,255.0,133.0,179.0);//call     hsv segmentation function to segment leaf
    cvtColor(seg_img, hsv_seg, CV_BGR2HSV);
    hsvSeg(seg_img,hsv_seg, hsv_infected, infected_area,0.09*255,0.01*255,0.1*255,0.14*255,1.0*255,1.0*255);//call hsv segmentation to segment infected areas
    imwrite( "C:/Image.jpg", filter_img ); 

    this->ui->ImageView_2->setPixmap(QPixmap("C:/Image.jpg"));// here the problem 
4

1 回答 1

0

试试这个:

cvtColor(mat, mat, CV_BGR2RGB);
QImage qimg((uchar*)mat.data, mat.cols, mat.rows, mat.step, QImage::Format_RGB888);
ui->label->setPixmap(QPixmap::fromImage(qimg));
于 2013-05-28T20:44:31.053 回答