在iOS视图中的模糊效果 [英] Blur effect in a view of iOS

查看:243
本文介绍了在iOS视图中的模糊效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用UIImagePicker来显示相机预览。

I want to use an UIImagePicker to have a camera preview being displayed. Over this preview I want to place an overlay view with controls.

是否可以将预览中的任何效果应用于相机显示?我特别需要对相机预览应用模糊效果。

Is it possible to apply any effects to the preview which will be displayed from camera? I particularly need to apply a blur effect to the camera preview.

所以我想从相机和重叠视图模糊预览控件。如果我决定从相机捕获静止图像,我需要它原来没有模糊效果。所以模糊效果只能应用于预览。

So I want to have a blurred preview from camera and overlay view with controls. If I decide to capture the still image from the camera, I need to have it original without blur effect. So blur effect must applied only to the preview.

这是可能使用这样的配置,或者可能与AVFoundation用于访问相机预览或可能以某种其他,或者这是不可能的

Is this possible using such configuration or maybe with AVFoundation being used for accessing the camera preview or maybe somehow else, or that's impossible at all?

推荐答案

使用AV基础,你可以做几乎所有你想要的,因为你可以从相机获取单帧, ,但它可能导致你在一个死胡同的实时应用模糊的图像是一个相当密集的任务与滞后的视频结果,可能会导致浪费时间的编码。我建议你使用James WebSster或OpenGL着色器的解决方案。看看这个由我最喜欢的大师布拉德写的真棒免费的图书馆 http ://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework 即使你没有找到正确的过滤器,也许它会导致你正确的实现你想做什么。
当然,正确的过滤器是高斯模糊,但我不知道是否支持,但你可以自己做。

With AV foundation you could do almost everything you want since you can obtain single frame from the camera and elaborate them, but it could lead you at a dead-end applying a blur on an image in realtime is a pretty intensive task with laggy video results, that could lead you to waste hours of coding. I would suggest you to use the solution of James WebSster or OpenGL shaders. Take a look at this awesome free library written by one of my favorite guru Brad http://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework even if you do not find the right filter, probably it will lead you to a correct implementation of what you want to do. The right filter is Gaussian blur of course, but I don't know if it is supported, but you could do by yourself.

几乎忘了说比iOS 5中你完全访问加速框架,由苹果,你应该看看这一点。

Almost forgot to say than in iOS 5 you have full access to the Accelerate Framework, made by Apple, you should look also into that.

这篇关于在iOS视图中的模糊效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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