【问题标题】:Cannot see IplImage in QGraphicsView在 QGraphicsView 中看不到 IplImage
【发布时间】:2012-04-30 17:15:03
【问题描述】:

我正在尝试在 QT 的 QGraphicsView 对象中显示 3D 场景(OpenGL-OpenCV)。场景有 5 个平面:上、下、右、左和前。我正在从我的网络摄像头拍摄图像并将它们映射到前平面。我已经成功展示了 5 个平面中的 4 个,前面的平面丢失了。

我按照本教程加载 OpenGL 场景:http://doc.trolltech.com/qq/qq26-openglcanvas.html

但是,我不知道如何处理要在 QT 对象中显示的 IplImage。你们有什么建议吗?

【问题讨论】:

    标签: qt opencv iplimage


    【解决方案1】:

    这是我从一篇博文中抢救出来的, 这将为您提供可以使用 Qt 显示的 QImage。 您应该根据自己的需要对其进行调整。

    QImage img;
    
    
    constructor()
    {
    // setup capture device
    CvCapture *cvCapture = cvCreateCapture(0);
    }
    
    
    getQImageFromIplImage()
    {
    // this frame gets a frame from capture device
    IplImage *frame = new IplImage();
    frame = cvQueryFrame(cvCapture);
    
    // create an IplImage with 8bit color depth
    IplImage *iplImg = cvCreateImage(cvSize(frame->width, frame->height),IPL_DEPTH_8U, 3);
    
    // copy image captured from capture device to new image, converting pixel data from OpenCV's default BGR format to Qt's RGB format
    cvCvtColor(frame, iplImg, CV_BGR2RGB);
    
    // create a this newly converted RGB pixel data with a QImage
    qImg = QImage((uchar *)iplImg->imageData, iplImg->width, iplImg->height, QImage::Format_RGB888);
    }
    

    如需完整代码,请查看: http://www.morethantechnical.com/2009/03/05/qt-opencv-combined-for-face-detecting-qwidgets/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-29
      • 2013-05-01
      • 2012-04-20
      • 1970-01-01
      • 2011-08-05
      • 2023-03-27
      • 1970-01-01
      • 2019-02-11
      相关资源
      最近更新 更多