• QT保存摄像头采集图片参考


    QImage A::IplImage2QImage(const IplImage *iplImage)
    {
        int height = iplImage->height;
        int width = iplImage->width; 
        if (iplImage->depth == IPL_DEPTH_8U && iplImage->nChannels == 3) {
            const uchar *qImageBuffer = (const uchar*)iplImage->imageData;
            QImage img(qImageBuffer, width, height, QImage::Format_RGB888); 
            return img.rgbSwapped();
        }
        else {
            // qWarning() << "Image cannot be converted.";  
            return QImage();
        }
    }
    
    void A::getFrame()
    {
        commentsTextBox->setText("getFrame");
        if (VI.isFrameNew(device1)) {
            VI.getPixels(device1, (unsigned char *)frame->imageData, false, true);
        }
        QImage qimg2 = IplImage2QImage(frame);
        m_Label->setPixmap(QPixmap::fromImage(qimg2));
        if (!qimg2.isNull()) {
            x = qimg2.save("C:\Data\test.jpg");
            commentsTextBox->append("notEmpty33"); 
        }
    }
      • Setting the environment variable QT_DEBUG_PLUGINS to 1 before running your application. 
        It will print the plugin loading attempts/successes/failures on the console.

      • Using a QImageWriter to get a more explicit error message than with just QImage::save or QPixmap::save :

    QImageWriter writer("/tmp/test.jpg");
    if(!writer.write(pixmap.toImage()))
    {
        qDebug() << writer.errorString();
    }
  • 相关阅读:
    ubuntu国内镜像源
    windows安装Pygraphviz
    python dict与collections.defaultdict的区别
    python生成 requirements.txt文件
    python list 和 dict前加星号
    Ubuntu安装Docker
    Zookeeper核心概念及读写流程
    docker安装mysql5和mysql8
    ubuntu docker更改默认镜像和容器存储位置
    训练篇-胸
  • 原文地址:https://www.cnblogs.com/ph829/p/6279373.html
Copyright © 2020-2023  润新知