How does QVideoFilterRunnable and OpenGL Context works together?

I'm trying to program an augmented reality (AR) app with C++, Qt, QML, OpenCV and OpenGL on Android.

Principle workflow:

  • The camera supplies a new videoframe (with openGL texture ID)
  • I capture this frin QVideoFilterRunnable::run(...)
  • Then I make some object recognition and calculate the new position (inside the videoframe) where I need to put objects in the 3D opengl scene
  • Render the openGL object newly
  • Bring it in the openGL rendering pipeline (fixed function or compatibility profile) TOGETHER with the videoframe as a background texture (zero copy) to maximise the render speed
  • Code example to manipulate the videoframe texture:

    QVideoFrame FilterRunnable::run(QVideoFrame* input, 
                                    const QVideoSurfaceFormat &sFormat,
                                    RunFlags flags) 
    {
        if(sFormat.handleType() == QAbstractVideoBuffer::GLTextureHandle)
        {
            QOpenGLContext* c = QOpenGLContext::currentContext();
            QOpenGLFunctions* f = c->functions();
    
            GLuint textID = input->handle().toInt();
            f->glBindTexture(GL_TEXTURE_2D,textID);
    
            float pixels[] = {
                0.0f, 0.0f, 0.0f,   1.0f, 1.0f, 0.0f,
                1.0f, 1.0f, 0.0f,   0.0f, 0.0f, 0.0f,
            };
    
            f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    
            f->glTexImage2D(GL_TEXTURE_2D, 
                            0, GL_RGB, 
                            2, 2, 0, 
                            GL_RGB, GL_FLOAT, pixels);
        }
    }
    

    With glTexImage2D() the screen becomes black whithout any error.

    The problem is that I did't find any infos how FilterRunnable::run() handles the OpenGL context in the background. I don't know how using glDrawArrays() , glViewport() without the standard functions initializeGL() , resizeGL() , paintGL() .

    For example, I want to combine the videoframe (mapped on a background polygon) together with arbitrary OpenGL objects in front of it.

    Where I can get info regarding this topic or what is the best way?

    链接地址: http://www.djcxy.com/p/63886.html

    上一篇: Mysql查询:文件排序时内部连接,限制和排序

    下一篇: QVideoFilterRunnable和OpenGL Context如何协同工作?