PDA

View Full Version : QT + OpenGL + OpenCV + GStreamer (Access violation)



Elijah Muhammad
2nd June 2013, 19:43
Hello, I'm developing application that uses GStreamer to take video from device then do processing with OpenCV and as GUI framework I use QT.

So... This app works on Linux well. But when I try to build it on Windows I got exception in QPainter constructor.

First-chance exception at 0x630373cc (QtOpenGLd4.dll) in guitool.exe: 0xC0000005: Access violation reading location 0xcdcdcdd5.
Unhandled exception at 0x630373cc (QtOpenGLd4.dll) in guitool.exe: 0xC0000005: Access violation reading location 0xcdcdcdd5.



QtOpenGLd4.dll!QScopedPointer<QGLFramebufferObjectPrivate,QScopedPointerDeleter<QGLFramebufferObjectPrivate> >::operator->() Line 112 + 0x3 bytes C++
QtOpenGLd4.dll!QGLFBOGLPaintDevice::context() Line 376 + 0xe bytes C++
QtOpenGLd4.dll!QGLPaintDevice::beginPaint() Line 86 + 0xd bytes C++
QtOpenGLd4.dll!QOpenGLPaintEngine::begin(QPaintDev ice * pdev) Line 1259 C++
QtGuid4.dll!QPainter::begin(QPaintDevice * pd) Line 1881 + 0x1d bytes C++
QtGuid4.dll!QPainter::QPainter(QPaintDevice * pd) Line 1508 C++
guitool.exe!WVideo::paintGL() Line 63 + 0x10 bytes C++
QtOpenGLd4.dll!QGLWidget::glDraw() Line 4627 C++
QtOpenGLd4.dll!QGLWidget::paintEvent(QPaintEvent * __formal) Line 4425 C++
QtGuid4.dll!QWidget::event(QEvent * event) Line 8518 C++
QtOpenGLd4.dll!QGLWidget::event(QEvent * e) Line 4408 C++
QtGuid4.dll!QApplicationPrivate::notify_helper(QOb ject * receiver, QEvent * e) Line 4557 + 0x11 bytes C++
QtGuid4.dll!QApplication::notify(QObject * receiver, QEvent * e) Line 4522 + 0x10 bytes C++
QtCored4.dll!QCoreApplication::notifyInternal(QObj ect * receiver, QEvent * event) Line 915 + 0x15 bytes C++
QtCored4.dll!QCoreApplication::sendSpontaneousEven t(QObject * receiver, QEvent * event) Line 234 + 0x38 bytes C++
QtGuid4.dll!QWidgetPrivate::drawWidget(QPaintDevic e * pdev, const QRegion & rgn, const QPoint & offset, int flags, QPainter * sharedPainter, QWidgetBackingStore * backingStore) Line 5594 + 0xe bytes C++
QtGuid4.dll!QWidgetPrivate::repaint_sys(const QRegion & rgn) Line 1659 C++
QtGuid4.dll!QWidgetPrivate::syncBackingStore() Line 1890 C++
QtGuid4.dll!QWidget::event(QEvent * event) Line 8665 C++
QtOpenGLd4.dll!QGLWidget::event(QEvent * e) Line 4408 C++
QtGuid4.dll!QApplicationPrivate::notify_helper(QOb ject * receiver, QEvent * e) Line 4557 + 0x11 bytes C++
QtGuid4.dll!QApplication::notify(QObject * receiver, QEvent * e) Line 4522 + 0x10 bytes C++
QtCored4.dll!QCoreApplication::notifyInternal(QObj ect * receiver, QEvent * event) Line 915 + 0x15 bytes C++
QtCored4.dll!QCoreApplication::sendEvent(QObject * receiver, QEvent * event) Line 231 + 0x39 bytes C++
QtCored4.dll!QCoreApplicationPrivate::sendPostedEv ents(QObject * receiver, int event_type, QThreadData * data) Line 1539 + 0xd bytes C++
QtCored4.dll!qt_internal_proc(HWND__ * hwnd, unsigned int message, unsigned int wp, long lp) Line 496 + 0x10 bytes C++
user32.dll!7e368734()
[Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]
user32.dll!7e368816()
user32.dll!7e3689cd()
user32.dll!7e368a10()
QtCored4.dll!QEventDispatcherWin32::processEvents( QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 810 C++
QtGuid4.dll!QGuiEventDispatcherWin32::processEvent s(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 1204 + 0x15 bytes C++
QtCored4.dll!QEventLoop::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 150 C++
QtCored4.dll!QEventLoop::exec(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 204 + 0x2d bytes C++
QtCored4.dll!QCoreApplication::exec() Line 1187 + 0x15 bytes C++
QtGuid4.dll!QApplication::exec() Line 3819 C++
guitool.exe!main(int argc, char * * argv) Line 19 + 0x6 bytes C++
guitool.exe!WinMain(HINSTANCE__ * instance, HINSTANCE__ * prevInstance, char * __formal, int cmdShow) Line 131 + 0x12 bytes C++
guitool.exe!__tmainCRTStartup() Line 547 + 0x2c bytes C
guitool.exe!WinMainCRTStartup() Line 371 C
kernel32.dll!7c817077()

this is the drawing code with GL initialization:




QGLFramebufferObject *fbo;
GLuint commands;

void WVideo::init(int w, int h)
{

im_width = w;
im_height = h;

glDeleteLists(commands, 1);
if (fbo){
delete fbo;
}
fbo = new QGLFramebufferObject(w, h);

commands = glGenLists(1);
glNewList(commands, GL_COMPILE);
glBegin(GL_QUADS);
glTexCoord2d( 1, 1);
glVertex2d( w-1, h-1);
glTexCoord2d( 0, 1);
glVertex2d( 0, h-1);
glTexCoord2d( 0, 0);
glVertex2d( 0, 0);
glTexCoord2d( 1, 0);
glVertex2d( w-1, 0);

glEnd();
glEndList();

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, w, h);
glOrtho(0.0, w-1, 0.0, h, -0.01, 0.0);
}

void WVideo::paintGL()
{
mutex.lock();

//if (!fbo) { init(800, 600); }
if (!fbo) { init(704, 576); }

if (img){
QPainter fbo_painter(fbo);
fbo_painter.drawImage(QRect(0, 0, im_width, im_height), *img );
fbo_painter.end();
}

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_TEXTURE_2D);

glPushMatrix();
glColor3d(255, 255, 255);
glCallList(commands);
glPopMatrix();
mutex.unlock();
}

ChrisW67
3rd June 2013, 07:24
Do you initialise fbo to zero in the constructor, or are you assuming it will start out life as zero?