My goal is to write a custom camera view controller that:
- Can take photos in all four interface orientations with both the back and, when available, front camera.
- Properly rotates and scales the preview “video” as well as the full resolution photo.
- Allows a (simple) effect to be applied to BOTH the preview “video” and full resolution photo.
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’s example uses a preset with 640×480 video dimensions and a default texture size of 1280×720. The iPhone 4 back camera delivers only 852×640 when the preset is AVCaptureSessionPresetPhoto.
iOS device camera video/photo dimensions when preset is AVCaptureSessionPresetPhoto:
- iPhone 4 back: video is 852×640 & photos are 2592×1936
- iPhone 4 front: video & photos are 640×480
- iPod Touch 4G back: video & photos are 960×720
- iPod Touch 4G front: video & photos are 640×480
- iPhone 3GS: video is 512×384 & photos are 2048×1536
Update
I got the same garbled video result when switching Brad Larson’s ColorTracking example (blog post) to use the AVCaptureSessionPresetPhoto.
The issue is that
AVCaptureSessionPresetPhotois 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 distorted from AVCaptureSessionDataOutput with AVCaptureSessionPresetPhoto