سؤال

Is there a way to pass an image as a name not as a path to Qpixmap in QT(C++),, for example i have the following code in which the processed image should be displayed using Qpixmap label but when i tried that i have to save it and then to pass it to Qpixmap to be displayed,,, but it's not an efficient way so could anybody help me please i'm new to Qt and have no experience..

    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 
هل كانت مفيدة؟

المحلول

Try this:

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));
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top