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();
    }
  • 相关阅读:
    关于java.lang.reflect.InvocationTargetException
    Java并发编程(三)后台线程(Daemon Thread)
    Lab 7-2
    Lab 7-1
    Lab 6-3
    Lab 6-2
    Lab 6-1
    Lab 5-1
    Lab 3-4
    Lab 3-3
  • 原文地址:https://www.cnblogs.com/ph829/p/6279373.html
Copyright © 2011-2022 走看看