Qt iOS:如何从QVideoFilterRunnable返回types为GLTextureHandle的QVideoFrame
我试图捕捉摄像头输出帧,并在GPUpipe道中进一步处理。 出于这个原因,将纹理作为GPU纹理来回转是最好的select。 从QVideoFilterRunnable类inheritance的run方法接收QVideoFrame对象的types不等于QAbstractVideoBuffer :: GLTextureHandle 。 它等于NoHandle
,我需要做map / unmap,并通过glTexImage
手动加载纹理,这不利于性能。 有没有可用于返回纹理名称的控制选项?
一些说明:
-
在Android上看起来不错。 返回的框架是质感,所以这就像一个魅力:
QVideoFrame* input = ...; GLuint texture = input->handle().toUInt(); f->glBindTexture(GL_TEXTURE_2D, texture);
-
一般来说,可能有iOS纹理cachingfunction:
CVPixelBufferRef pixelBuffer = ...; CVOpenGLESTextureCacheCreateTextureFromImage(..., pixelBuffer, ..., &textureRef); texture = CVOpenGLESTextureGetName(textureRef);
CVPixelBufferRef
可以手动创build(我还需要使用map
):
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
指针的值来创buildcaching纹理:
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);