CVOpenGLESTexture方法types的官方文档在哪里?

我试过谷歌和stackoverflow,但我似乎无法find官方文档的函数,开始与CVOpenGLESTexture 。 我可以看到他们是从核心video,我知道他们是在iOS 5添加,但search文档不给我任何东西。

我正在寻找关于参数的信息,他们做了什么,如何使用他们等,像在其他苹果的框架。

到目前为止,我所能做的只是点击它来查看信息,但是这感觉非常奇怪。 或者有没有办法添加这个,所以它可以显示在右侧的快速帮助xcode?

谢谢,如果这是一个愚蠢的问题,很抱歉。

PD:核心video参考指南似乎也不能解释这些。

不幸的是,这些新function真的没有任何文档。 您现在要find的最好的方法是在CVOpenGLESTextureCache.h头文件中,您将在其中看到函数参数的基本说明:

 /*! @function CVOpenGLESTextureCacheCreate @abstract Creates a new Texture Cache. @param allocator The CFAllocatorRef to use for allocating the cache. May be NULL. @param cacheAttributes A CFDictionaryRef containing the attributes of the cache itself. May be NULL. @param eaglContext The OpenGLES 2.0 context into which the texture objects will be created. OpenGLES 1.x contexts are not supported. @param textureAttributes A CFDictionaryRef containing the attributes to be used for creating the CVOpenGLESTexture objects. May be NULL. @param cacheOut The newly created texture cache will be placed here @result Returns kCVReturnSuccess on success */ CV_EXPORT CVReturn CVOpenGLESTextureCacheCreate( CFAllocatorRef allocator, CFDictionaryRef cacheAttributes, void *eaglContext, CFDictionaryRef textureAttributes, CVOpenGLESTextureCacheRef *cacheOut) __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0); 

属性字典中的元素越困难,不幸的是,您需要查找示例以正确使用这些函数。 Apple拥有GLCameraRipple和RosyWriter示例,展示了如何使用BGRA和YUVinput色彩格式的快速纹理上传path。 苹果公司还在WWDC上提供了ChromaKey的例子(这些例子可能与video一起被访问),演示了如何使用这些纹理caching从OpenGL ES纹理中提取信息。

我刚刚在GPUImage框架中获得了这个快速的纹理上传工作(在该链接中提供了源代码),所以我将阐述我能parsing出来的东西。 首先,我使用下面的代码创build一个纹理caching:

 CVReturn err = CVOpenGLESTextureCacheCreate(kCFAllocatorDefault, NULL, (__bridge void *)[[GPUImageOpenGLESContext sharedImageProcessingOpenGLESContext] context], NULL, &coreVideoTextureCache); if (err) { NSAssert(NO, @"Error at CVOpenGLESTextureCacheCreate %d"); } 

其中所指的上下文是为OpenGL ES 2.0configuration的EAGLContext。

我使用这个来保持来自iOS设备相机的video帧在video内存中,我使用下面的代码来做到这一点:

 CVPixelBufferLockBaseAddress(cameraFrame, 0); CVOpenGLESTextureRef texture = NULL; CVReturn err = CVOpenGLESTextureCacheCreateTextureFromImage(kCFAllocatorDefault, coreVideoTextureCache, cameraFrame, NULL, GL_TEXTURE_2D, GL_RGBA, bufferWidth, bufferHeight, GL_BGRA, GL_UNSIGNED_BYTE, 0, &texture); if (!texture || err) { NSLog(@"CVOpenGLESTextureCacheCreateTextureFromImage failed (error: %d)", err); return; } outputTexture = CVOpenGLESTextureGetName(texture); glBindTexture(GL_TEXTURE_2D, outputTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // Do processing work on the texture data here CVPixelBufferUnlockBaseAddress(cameraFrame, 0); CVOpenGLESTextureCacheFlush(coreVideoTextureCache, 0); CFRelease(texture); outputTexture = 0; 

这会从纹理caching创build一个新的CVOpenGLESTextureRef,代表一个OpenGL ES纹理。 该纹理基于相机传入的CVImageBufferRef。 然后从CVOpenGLESTextureRef中检索纹理,并为其设置适当的参数(这在我的处理过程中似乎是必需的)。 最后,我做了关于纹理的工作,并在完成后进行清理。

这个快速上传过程在iOS设备上产生了真正的效果。 它将iPhone 4S上的一个640×480帧的video上传和处理时间从9.0毫秒减less到1.8毫秒。

我听说,这也反过来 ,以及可能允许replaceglReadPixels()在某些情况下,但我还没有尝试这个。

苹果终于在一个多星期前发布了文档 。