zoukankan      html  css  js  c++  java
  • 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();
    }
  • 相关阅读:
    QSettings读写注册表、配置文件
    QSettings介绍
    桥接模式
    Qt之启动外部程序
    StringJDBC更改数据库的两种方式
    写代码注意事项
    maven仓库
    java关闭流,解压缩后的清除
    Java删除文件夹和文件
    浏览器禁用后退
  • 原文地址:https://www.cnblogs.com/ph829/p/6279373.html
Copyright © 2011-2022 走看看