gpt4 book ai didi

iphone - CVOpenGLESTextureCacheCreateTextureFromImage 返回 -6683(kCVReturnPixelBufferNotOpenGLCompatible)

转载 作者:行者123 更新时间:2023-12-03 18:29:01 26 4
gpt4 key购买 nike

我从视频帧中分别​​提取了Y U V数据并将它们保存在data[0],data[1],data[2];帧大小为640*480;现在我创建 pixelBuffer 如下:

void *pYUV[3] = {data[0], data[1], data[2]};
size_t planeWidth = {640, 320, 320};
size_t planeHeight = {480, 240, 240};
size_t planeBytesPerRow = {640, 320, 320};
CVReturn renturn = CVPixelBufferCreateWithPlanarBytes(kCFAllocatorDefault,
640,
480,
kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange,
nil,
nil,
3,
pYUV,
planeWidth,
planeHeight,
planeBytesPerRow,
nil,
nil, nil, &_pixelBuffer);
CVPixelBufferLockBaseAddress(_pixelBuffer, 0);
CVPixelBufferRetain(_pixelBuffer);
// Periodic texture cache flush every frame
CVOpenGLESTextureCacheFlush(_textureCache, 0);

// The Buffer cannot be used with OpenGL as either its size, pixelformat or attributes are not supported by OpenGL
glActiveTexture(GL_TEXTURE0);
CVReturn err = CVOpenGLESTextureCacheCreateTextureFromImage(kCFAllocatorDefault,
_textureCache,
_pixelBuffer,
NULL,
GL_TEXTURE_2D,
GL_LUMINANCE,
im.width,
im.height,
GL_LUMINANCE,
GL_UNSIGNED_BYTE,
0,
&_yTexture);

if (!_yTexture || err) {
NSLog(@"CVOpenGLESTextureCacheCreateTextureFromImage failed (error: %d)", err);
return;
}
glBindTexture(CVOpenGLESTextureGetTarget(_yTexture), CVOpenGLESTextureGetName(_yTexture));
CVPixelBufferUnlockBaseAddress(_pixelBuffer, 0);

但错误是 -6638,文档只是指出“由于不支持的缓冲区大小、像素格式或属性,像素缓冲区与 OpenGL 不兼容。”这对我没有多大帮助。

如何修复它?

最佳答案

您的源图像/视频帧的分辨率是否为 2 的幂?如果没有,您必须在创建纹理之前调整其大小。

关于iphone - CVOpenGLESTextureCacheCreateTextureFromImage 返回 -6683(kCVReturnPixelBufferNotOpenGLCompatible),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10047159/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com