zoukankan      html  css  js  c++  java
  • QLabel显示opencv Mat图片

    QLabel显示opencv  Mat图片

    void showImgOnLabel(QLabel* labelParam, cv::Mat imgParam, int showType)
    {
        cv::Mat rgb;
        QImage img;
    
        if (showType==1)
        {
            cv::resize(imgParam, imgParam, cv::Size(640, 480));
        }
        else if (showType==2)
        {
            cv::resize(imgParam, imgParam, cv::Size(160, 120));
        }
    
        if (imgParam.channels() == 3)
        {
            cv::cvtColor(imgParam, rgb, CV_BGR2RGB);
            img = QImage((const uchar*)(rgb.data), rgb.cols, rgb.rows, rgb.cols*rgb.channels(), QImage::Format_RGB888);
        }
        else
        {
            img = QImage((const uchar*)(imgParam.data), imgParam.cols, imgParam.rows, imgParam.cols*imgParam.channels(), QImage::Format_Indexed8);
        }
        labelParam->clear();
        labelParam->setPixmap(QPixmap::fromImage(img));
        //this->main_ui.labelWin1->resize(this->main_ui.labelWin1->pixmap()->size());
        //labelParam->resize(QSize(640, 480));
        labelParam->show();
    }

    #################################

    QQ 3087438119
  • 相关阅读:
    几道cf水题
    cf水题
    一道cf水题
    c++list用法
    c++map用法
    c++ vector常见用法
    c++string,常见用法总结
    复变函数考试后的反思
    [FZYZOJ 1204] 零和问题
    [FZYZOJ 1202] 金坷垃
  • 原文地址:https://www.cnblogs.com/herd/p/15464144.html
Copyright © 2011-2022 走看看