qt - 在QGraphicsView中看不到IplImage

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

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

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

最佳答案

这是我从博客文章中挽救的东西,
这将为您提供可以使用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/

https://stackoverflow.com/questions/5398227/

相关文章:

opencv - 如何在 OpenCV 中制作 double CvSeq?

docker - 如何避免使用太多容器来破坏 Docker?

visual-c++ - Opencv中cv MatchTemplate()函数的用法

opencv - 为什么OpenCV的SVM中只有一个支持向量

visual-c++ - Opencv中的相关函数

c# - 如何在C#的Open CV中使USB摄像机工作?

iphone - opencv在iPhone中获取子图像

c# - Blob 检测中的大位图图像内存分配,C# .Net

opencv - opencv_gpu编译问题

python - OpenCV Python 库中的 cv.cornerSubPix 参数