ideoFilterRunnable返回类型为GLTexture

ideoFilterRunnable返回类型为GLTexture

本文介绍了Qt iOS:如何从QVideoFilterRunnable返回类型为GLTextureHandle的QVideoFrame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试捕获相机的输出帧,并在GPU管道中对其进行进一步处理.因此,将帧恢复为GPU纹理是最佳选择.从 QVideoFilterRunnable 类继承之后.qt.io/qt-5/qvideofilterrunnable.html#run"rel =" nofollow>运行方法 QVideoFrame 对象的类型不等于 QAbstractVideoBuffer :: GLTextureHandle .它等于NoHandle,我需要通过glTexImage手动进行贴图/取消映射和加载纹理,这对性能不利.有没有可以用于返回纹理名称的控件选项?

I'm trying to capture camera output frame and process it further in GPU pipeline. For this reason returing frame as a GPU texture is the best option. After inheriting from QVideoFilterRunnable class received by run method QVideoFrame objects has type which is not equal to QAbstractVideoBuffer::GLTextureHandle. It's equal to NoHandle and I need to do map/unmap and load texture manually by glTexImage, which is not good for performance. Is there any control options that can be used to return texture name?

一些注意事项:

  • 在Android上看起来不错.返回的帧是纹理,因此就像魅力一样:

  • Looks good on Android. Returned frame is texture so this works like a charm:

QVideoFrame* input = ...;
GLuint texture = input->handle().toUInt();
f->glBindTexture(GL_TEXTURE_2D, texture);

  • 一般来说,可能有iOS纹理缓存功能:

  • It's possible in general, there is iOS texture cache feature:

    CVPixelBufferRef pixelBuffer = ...;
    CVOpenGLESTextureCacheCreateTextureFromImage(..., pixelBuffer, ..., &textureRef);
    texture = CVOpenGLESTextureGetName(textureRef);
    

  • 推荐答案

    CVPixelBufferRef可以手动创建(我仍然需要使用map):

    CVPixelBufferRef can be created manually (I do need to use map still):

    frame.map(QAbstractVideoBuffer::ReadOnly);
    
    CVPixelBufferRef x;
    CVPixelBufferCreateWithBytes(
        kCFAllocatorDefault,
        frame.size().width(),
        frame.size().height(),
        kCVPixelFormatType_32BGRA,
        frame.bits(),
        frame.bytesPerLine(),
        nullptr, // releaseCallback
        nullptr, // releaseRefCon
        nullptr, // pixelBufferAttributes
        &x
    );
    

    使用CVPixelBufferRef指针的值创建缓存纹理:

    Use value of CVPixelBufferRef pointer to create cache texture:

    CVOpenGLESTextureRef texRef;
    CVOpenGLESTextureCacheCreateTextureFromImage(
        kCFAllocatorDefault,
        textureCache,
        x,
        NULL, // texture attributes
        GL_TEXTURE_2D,
        GL_RGBA, // opengl format
        inputW,
        inputH,
        inputPixelFormat,
        GL_UNSIGNED_BYTE,
        0,
        &texRef
    );
    

    获取纹理名称:

    inputTexId = CVOpenGLESTextureGetName(texRef);
    

    这篇关于Qt iOS:如何从QVideoFilterRunnable返回类型为GLTextureHandle的QVideoFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    07-29 23:56