我正在尝试在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/
关于qt - 在QGraphicsView中看不到IplImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5398227/