gpt4 book ai didi

iphone - 从捕获的视频帧创建 openGL 纹理以在视频上覆盖 openGL View 的替代方案? (iPhone)

转载 作者:行者123 更新时间:2023-12-03 18:56:00 24 4
gpt4 key购买 nike

这主要与增强现实类型的应用程序相关。 Apple 在此处提供了有关如何使用 AVCaptureSession 捕获视频帧(并在需要时将其另存为图像)的信息:

http://developer.apple.com/library/ios/#qa/qa2010/qa1702.html

我知道可以从捕获的视频帧创建 openGL 纹理,然后将其用作 openGL View 中的背景,在其上覆盖其他图形。

我想知道这个方法是否还有其他替代方法?上面提到的方法可能是最好的(我不知道是否是),但如果有其他方法可以尝试,那么最好知道。例如,有没有办法将 openGL View 直接覆盖在 AVCaptureVideoPreviewLayer 上?

最佳答案

您确实可以将 OpenGL 内容分层到 AVCaptureVideoPreviewLayer 等内容上,但您的性能会受到影响。 Apple 强烈建议您不要将非不透明 OpenGL ES 内容叠加在其他显示元素之上。来自 OpenGL ES Programming Guide for iOS :

For the absolute best performance, your application should rely solely on OpenGL ES to render your content. To do this, size the view that holds your CAEAGLLayer object to match the screen, set its opaque property to YES, and ensure that no other Core Animation layers or views are visible. If your OpenGL ES layer is composited on top of other layers, making your CAEAGLLayer object opaque reduces but doesn’t eliminate the performance cost.

If your CAEAGLLayer object is blended on top of layers underneath it in the layer hierarchy, the renderbuffer’s color data must be in a premultiplied alpha format to be composited correctly by Core Animation. Blending OpenGL ES content on top of other content has a severe performance penalty.

老实说,将视频作为纹理拉入,然后将其显示为 3D 叠加层后面的广告牌,这确实并不难。我的示例应用程序here将相机视频传递到 OpenGL ES (2.0) 纹理以显示到屏幕上。只需进行一些修改,您就可以将 3D 内容放置在其上。与尝试在 AVCaptureVideoPreviewLayer 之上绘制非不透明 3D 内容相比,这将为您提供更好的性能。

但是,如果您只是想通过 OpenGL ES 内容显示简单的静态 UIView,则可以在不会造成太大性能损失的情况下完成(根据我的经验,帧速率降低约 5%)。

关于iphone - 从捕获的视频帧创建 openGL 纹理以在视频上覆盖 openGL View 的替代方案? (iPhone),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4473894/

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