CVOpenGLESTextureCacheCreateTextureFromImage 错误

CVOpenGLESTextureCacheCreateTextureFromImage error

我正在处理应用程序的第二个版本更新。一切正常,但突然间我开始收到此错误。我正在使用 GPUImage 库进行过滤。我正在 iPhone 6/iOS 8.3 上测试我的应用程序。我还检查了我的旧代码,但我开始遇到同样的错误。谁帮我解决这个问题。

我们有一些调用 CVPixelBufferCreate 的代码传递了错误的参数。据我所知,这来自一些示例代码,之后有一些错误的复制和粘贴,所以你的可能有同样的错误。

CVPixelBufferCreate 采用属性字典。一些键,如 kCVPixelBufferOpenGLESCompatibilityKey 采用 CFBoolean,但我们传递的是字典。这种风格有效:

NSDictionary *attrs = @{ (NSString*)kCVPixelBufferIOSurfacePropertiesKey : @{},
                         (NSString*)kCVPixelBufferOpenGLESCompatibilityKey: @YES}; <-- we had @{} !

err = CVPixelBufferCreate(kCFAllocatorDefault, width, height, formatType, (__bridge CFDictionaryRef)attrs, &pixelBuffer);

我正在使用 GPUImage 1.6.0 并看到同样的问题。试图破解建议的提案 - 但没有帮助。还有其他 ideas/suggestions 吗?

CFDictionarySetValue(attrs, kCVPixelBufferIOSurfacePropertiesKey, empty);
CFDictionarySetValue(attrs, kCVPixelBufferOpenGLESCompatibilityKey, kCFBooleanTrue);

CVReturn err = CVPixelBufferCreate(kCFAllocatorDefault, (int)_size.width, (int)_size.height, kCVPixelFormatType_32BGRA, attrs, &renderTarget);

我从 Brad Larsen 那里得到了这个解决方案,我认为他是对的。 "If you're doing filtering directly from the camera, don't use -imageByFilteringImage: and intermediary UIImages. This will be horribly expensive, both in memory consumption and performance, because you have to convert to and from UIImages on the CPU. Instead, chain filters from a GPUImageVideoCamera instance."