1

Using the GPUImage camera I set my camera up like this

- (void)setupSessionWithImageView:(GPUImageView *)captureView
{
    GPUImageStillCamera *stillCamera = [[GPUImageStillCamera alloc] init];
    GPUImageGammaFilter *colorFilter = [[GPUImageGammaFilter alloc] init];
    [stillCamera addTarget:colorFilter];
    [colorFilter addTarget:captureView];

    self.colorFilter = colorFilter;
    self.stillCamera = stillCamera;
    self.captureView = captureView;

    [stillCamera startCameraCapture];
}

In order to mimic Apple's iPad camera when viewWillTransitionToSize: is called on my View Controller I update the outputImageOrientation on the still camera. This rotates the video preview so that it maintains the correct orientation as the iPad's orientation changes.

- (void)setOrientation:(UIInterfaceOrientation)interfaceOrientation
{
        if (interfaceOrientation == UIInterfaceOrientationUnknown) { // default to portrait if we don't know
            interfaceOrientation = UIInterfaceOrientationPortrait;
        }

    self.stillCamera.outputImageOrientation = interfaceOrientation;
}

My problem is when I capture a photo with this set up using iOS 9 all landscape images report their size as if they were portrait images (so the short side is measurement for width and long for height), however they report their orientation correctly. The What's New in iOS 9 Guide does not indicate any changes to AVFoundation that sound like they could effect this. Leaving the outputImageOrientation as Portrait solves this but prevents me from mimicking Apple's native camera functionality on the iPad by rotating the view.

- (void)captureImage
{
    GPUImageStillCamera *stillCamera = self.stillCamera;

    [stillCamera capturePhotoAsImageProcessedUpToFilter:self.colorFilter withCompletionHandler:^(UIImage *processedImage, NSError *error) {
        NSLog(@"image orientation %ld", (long)processedImage.imageOrientation);
        NSLog(@"image size %f width x %f height", processedImage.size.width, processedImage.size.height);

    }];
}

Is there a problem with my implementation of GPUImage and/or how I'm handling orientation changes in the camera? The entire sample project can be found on my git page. In iOS 8 and before the image reported a size the accurately reflected it's orientation property.

Nat Osten
  • 278
  • 4
  • 11

0 Answers0