Permalink
Browse files

Made the PNG and UIImage still photo capture routines account for the…

… glitches from photos taken by the front-facing camera.
  • Loading branch information...
1 parent d1e13fe commit 74d48b879b4debdb3960c16b1e71b9fed31d0cbe @BradLarson committed Aug 29, 2012
@@ -28,7 +28,7 @@ - (void)viewDidLoad
videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
videoCamera.horizontallyMirrorFrontFacingCamera = NO;
- videoCamera.horizontallyMirrorRearFacingCamera = YES;
+ videoCamera.horizontallyMirrorRearFacingCamera = NO;
filter = [[GPUImageSepiaFilter alloc] init];
@@ -121,9 +121,14 @@ - (void)capturePhotoAsImageProcessedUpToFilter:(GPUImageOutput<GPUImageInput> *)
}
else
{
- dispatch_semaphore_signal(frameRenderingSemaphore);
- [self captureOutput:photoOutput didOutputSampleBuffer:imageSampleBuffer fromConnection:[[photoOutput connections] objectAtIndex:0]];
- dispatch_semaphore_wait(frameRenderingSemaphore, DISPATCH_TIME_FOREVER);
+ // This is a workaround for the corrupt images that are sometimes returned when taking a photo with the front camera and using the iOS 5.0 texture caches
+ AVCaptureDevicePosition currentCameraPosition = [[videoInput device] position];
+ if ( (currentCameraPosition != AVCaptureDevicePositionFront) || (![GPUImageOpenGLESContext supportsFastTextureUpload]))
+ {
+ dispatch_semaphore_signal(frameRenderingSemaphore);
+ [self captureOutput:photoOutput didOutputSampleBuffer:imageSampleBuffer fromConnection:[[photoOutput connections] objectAtIndex:0]];
+ dispatch_semaphore_wait(frameRenderingSemaphore, DISPATCH_TIME_FOREVER);
+ }
}
UIImage *filteredPhoto = [finalFilterInChain imageFromCurrentlyProcessedOutput];
@@ -215,9 +220,14 @@ - (void)capturePhotoAsPNGProcessedUpToFilter:(GPUImageOutput<GPUImageInput> *)fi
}
else
{
- dispatch_semaphore_signal(frameRenderingSemaphore);
- [self captureOutput:photoOutput didOutputSampleBuffer:imageSampleBuffer fromConnection:[[photoOutput connections] objectAtIndex:0]];
- dispatch_semaphore_wait(frameRenderingSemaphore, DISPATCH_TIME_FOREVER);
+ // This is a workaround for the corrupt images that are sometimes returned when taking a photo with the front camera and using the iOS 5.0 texture caches
+ AVCaptureDevicePosition currentCameraPosition = [[videoInput device] position];
+ if ( (currentCameraPosition != AVCaptureDevicePositionFront) || (![GPUImageOpenGLESContext supportsFastTextureUpload]))
+ {
+ dispatch_semaphore_signal(frameRenderingSemaphore);
+ [self captureOutput:photoOutput didOutputSampleBuffer:imageSampleBuffer fromConnection:[[photoOutput connections] objectAtIndex:0]];
+ dispatch_semaphore_wait(frameRenderingSemaphore, DISPATCH_TIME_FOREVER);
+ }
}
NSData *dataForPNGFile = nil;

0 comments on commit 74d48b8

Please sign in to comment.