Need suggestion how to generate current scene image in performance sensitive app

  • I am working on app that is doing offscreen rendering (QOffscreenSurface / QOpenGLFramebufferObject).
    Once per every frame I have to get scene image (and process it)

    My current approach is to (on main thread) take image from QOpenGLFramebufferObject and process it. See below.
    Unfortunatelly QOpenGLFramebufferObject::toImage() executes very very slow, causing that my app can not render more then 5-8 fps.
    Without call to QOpenGLFramebufferObject::toImage(), I am getting easily 30fps+.

    When i make fbo copy (QOpenGLFramebufferObject::blitFramebuffer(workerFbo, m_fbo)) and pass workerFbo to worker thread to do toImage() on it, I am getting

    QOpenGLFramebufferObject::toImage() called without a current context
    1. Is there any other (faster) approach to get current scene image ?
    2. How to copy / set context on worker thread, so that I can do QOpenGLFramebufferObject::toImage() on worker thread ?

    Current approach

    MySceneRenderer::renderNext() {
        ... on main thread
        //get image from current QOpenGLFramebufferObject m_fbo
        QImage fboImage(m_fbo->toImage());
        //process image

  • Lifetime Qt Champion


    Out of curiosity, what processing do you need to apply ?

  • @SGaist
    ... take portion of overall scene, and stream to remote clients.
    Planning to use GStreamer/gst-rtsp-server to stream out. Running on separate thread.
    So far bottleneck is converting framebuffer to image ...

  • Lifetime Qt Champion

    Then you should check the QtGStreamer module. It might make things easier.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.