CVOpenGLESTexture方法类型的官方文档在哪里? [英] Where is the official documentation for CVOpenGLESTexture method types?

查看:188
本文介绍了CVOpenGLESTexture方法类型的官方文档在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了google和stackoverflow,但似乎无法找到以 CVOpenGLESTexture 开头的函数的官方文档。我可以看到它们来自核心视频,我知道它们是在iOS 5上添加的,但搜索文档并没有给我任何东西。

I tried google and stackoverflow but I cant seem to find the oficial documentation for functions that start with CVOpenGLESTexture. I can see they are from core Video, and I know they were added on iOS 5 but searching the documentation doesnt give me anything.

我正在寻找有关参数,他们做什么,如何使用它们等,就像在其他苹果框架中一样。

I am looking for the information about the parameters, what they do, how to use them etc. like in the other apple frameworks.

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

So far all I can do is command click on it to see the information but this feels super weird. Or is there a way to add this so it can be displayed on the quick help on the right on xcode?

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

Thanks and sorry if it is a stupid question.

PD:核心视频参考指南似乎也没解释这些。

PD: The core Video reference guide doesnt seem to explain these either.

推荐答案

不幸的是,确实没有关于这些新功能的任何文档。你现在要找到的最好的是在 CVOpenGLESTextureCache.h 头文件中,你会看到函数参数的基本描述:

Unfortunately, there really isn't any documentation on these new functions. The best you're going to find right now is in the CVOpenGLESTextureCache.h header file, where you'll see a basic description of the function parameters:

/*!
    @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和YUV输入颜色格式的快速纹理上传路径。 Apple还在WWDC上提供了ChromaKey示例(可能仍然可以与视频一起访问),演示了如何使用这些纹理缓存从OpenGL ES纹理中提取信息。

The more difficult elements are the attributes dictionaries, which unfortunately you need to find examples of in order to use these functions properly. Apple has the GLCameraRipple and RosyWriter examples that show off how to use the fast texture upload path with BGRA and YUV input color formats. Apple also provided the ChromaKey example at WWDC (which may still be accessible along with the videos) that demonstrated how to use these texture caches to pull information from an OpenGL ES texture.

我刚刚在我的 GPUImage 框架中进行了快速纹理上传工作(源代码可在此处获得)链接),所以我将列出我能够解析的内容。首先,我使用以下代码创建纹理缓存:

I just got this fast texture uploading working in my GPUImage framework (the source code for which is available at that link), so I'll lay out what I was able to parse out of this. First, I create a texture cache using the following code:

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

其中提到的上下文是为OpenGL ES 2.0配置的EAGLContext。

where the context referred to is an EAGLContext configured for OpenGL ES 2.0.

我使用它来保存视频内存中iOS设备相机的视频帧,我使用以下代码执行此操作:

I use this to keep video frames from the iOS device camera in video memory, and I use the following code to do this:

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;

这将从纹理缓存中创建一个新的CVOpenGLESTextureRef,表示OpenGL ES纹理。此纹理基于相机传入的CVImageBufferRef。然后从CVOpenGLESTextureRef中检索该纹理并为其设置适当的参数(这在我的处理中似乎是必要的)。最后,我在纹理上做了我的工作并在完成后进行清理。

This creates a new CVOpenGLESTextureRef, representing an OpenGL ES texture, from the texture cache. This texture is based on the CVImageBufferRef passed in by the camera. That texture is then retrieved from the CVOpenGLESTextureRef and appropriate parameters set for it (which seemed to be necessary in my processing). Finally, I do my work on the texture and clean up when I'm done.

这个快速上传过程在iOS设备上产生了真正的不同。在iPhone 4S上上传和处理单个640x480视频帧的时间从9.0毫秒到1.8毫秒。

This fast upload process makes a real difference on the iOS devices. It took the upload and processing of a single 640x480 frame of video on an iPhone 4S from 9.0 ms to 1.8 ms.

听说这种情况正好相反,如好吧,这可能允许在某些情况下替换 glReadPixels(),但我还没试过。

I've heard that this works in reverse, as well, which might allow for the replacement of glReadPixels() in certain situations, but I've yet to try this.

这篇关于CVOpenGLESTexture方法类型的官方文档在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆