开发者

How do you show live photo preview effects similar to apps Path and Camera Sutra?

I understand and have created an app that displays the preview 开发者_如何学Pythonof what is coming from the camera using AVCaptureVideoPreviewLayer and I know how to capture frames and manipulate them but iterating over each frame pixel by pixel is too slow, drags the frame rate way down. How do apps like Path and Camera Sutra do live effect previews and maintain a good frame rate, I imagine OpenGL is one option, is there another?


The more work you can delegate to the GPU, the better the app will perform. Without a doubt, the most efficient option for camera effects would be, as you mentioned, to handle the frame processing in an OpenGL ES 2.0 shader, and then display the transformed frame as a texture. If I were to venture a guess, I would say this is how apps like the ones you mention function under the hood.

On the other end of the spectrum, you could avoid OpenGL entirely and stay within the comfortable realm of C / Objective-C. It sounds like you've gotten as far as using AVFoundation to pump camera data into your app, iterating over the pixel data right there, then building a UIImage and loading it into a UIImageView for display. I've had marginal luck with this approach only on the beefy iPad 2 for simple effects, but it's still molasses compared to the OpenGL approach.

Either way, the AVCaptureVideoPreviewLayer is not going to help you at all: You have no access to the data it uses to display its preview.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜