将效果应用于iPhone相机预览“视频"使用OpenGL [英] Applying Effect to iPhone Camera Preview "Video" Using OpenGL

查看:109
本文介绍了将效果应用于iPhone相机预览“视频"使用OpenGL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是编写一个自定义的相机视图控制器,该控制器:

My goal is to write a custom camera view controller that:

  1. 可以同时使用后置摄像头和前置摄像头(如果有)拍摄所有四个界面方向的照片.
  2. 正确旋转和缩放预览视频"以及全分辨率照片.
  3. 允许将(简单)效果应用于预览视频"和全分辨率照片.

此问题中记录了我以前的努力.我的最新尝试是修改Apple的示例GLVideoFrame(来自WWDC 2010).但是,当会话预设为AVCaptureSessionPresetPhoto时,我无法使iPhone 4正确显示预览视频".

My previous effort is documented in this question. My latest attempt was to modify Apple's sample GLVideoFrame (from WWDC 2010). However, I have not been able to get the iPhone 4 to display the preview "video" properly when the session preset is AVCaptureSessionPresetPhoto.

有人尝试过此方法还是知道为什么该示例不适用于此预设?

Has anyone tried this or know why the example doesn't work with this preset?

Apple的示例使用具有640x480视频尺寸的预设和默认的1280x720纹理尺寸.当预设为AVCaptureSessionPresetPhoto时,iPhone 4后置摄像头仅提供852x640.

Apple's example uses a preset with 640x480 video dimensions and a default texture size of 1280x720. The iPhone 4 back camera delivers only 852x640 when the preset is AVCaptureSessionPresetPhoto.

当预设为AVCaptureSessionPresetPhoto时,iOS设备相机的视频/照片尺寸:

iOS device camera video/photo dimensions when preset is AVCaptureSessionPresetPhoto:

  • iPhone 4背面:视频为852x640&照片是2592x1936
  • iPhone 4前面板:视频和视频照片是640x480
  • iPod Touch 4G背面:视频和视频;照片是960x720
  • iPod Touch 4G正面:视频和视频;照片是640x480
  • iPhone 3GS:视频为512x384&照片是2048x1536

更新

当切换Brad Larson的ColorTracking示例时,我得到了相同的乱码的视频结果(<要使用的href ="http://www.sunsetlakesoftware.com/2010/10/22/gpu-accelerated-video-processing-mac-and-ios" rel ="nofollow noreferrer">博客帖子) AVCaptureSessionPresetPhoto.

I got the same garbled video result when switching Brad Larson's ColorTracking example (blog post) to use the AVCaptureSessionPresetPhoto.

推荐答案

问题在于,AVCaptureSessionPresetPhoto现在可以识别上下文,并根据显示视频还是静止图像而以不同的分辨率运行.

The issue is that AVCaptureSessionPresetPhoto is now context-aware and runs in different resolutions based on whether you are displaying video or still image captures.

此模式的实时预览有所不同,因为它会用额外的字节填充行.我猜这是某种硬件优化.

The live preview is different for this mode because it pads the rows with extra bytes. I'm guessing this is some sort of hardware optimization.

无论如何,您可以在这里查看我如何解决该问题:

In any case, you can see how I solved the problem here:

iOS CVImageBuffer从AVCaptureSessionDataOutput和AVCaptureSessionPresetPhoto变形了

这篇关于将效果应用于iPhone相机预览“视频"使用OpenGL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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