jpegStillImageNSDataRepresentation不尊重镜像?

时间:2011-10-26 04:37:27

标签: ios avfoundation

我正在使用jpegStillImageNSDataRepresentation从iOS设备(iOS 5.0)上的前置摄像头捕获静止图像。

我正在使用AVCaptureVideoPreviewLayer在拍摄图像之前显示前置摄像头的输出。默认情况下,显示器是镜像的,我不会调整它。

捕获的静止图像镜像(即,与预览图层显示的内容相比,它围绕垂直轴翻转)。我希望它被镜像。任何想法如何实现?

以下是相关代码:

- (void) captureStillImage {
    AVCaptureConnection *stillImageConnection = [stillImageOutput connectionWithMediaType:AVMediaTypeVideo];        
    UIDeviceOrientation curDeviceOrientation = [[UIDevice currentDevice] orientation];
    AVCaptureVideoOrientation avcaptureOrientation = [self avOrientationForDeviceOrientation:curDeviceOrientation];
    [stillImageConnection setVideoOrientation:avcaptureOrientation];

    [stillImageOutput setOutputSettings:[NSDictionary dictionaryWithObject:AVVideoCodecJPEG 
                                                                    forKey:AVVideoCodecKey]]; 

    [stillImageOutput captureStillImageAsynchronouslyFromConnection:stillImageConnection completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
        if (!error) {            
            NSData *jpegData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
            UIImage *image = [UIImage imageWithData:jpegData];
            [self showImage:image];
        }                        
    }];
}

0 个答案:

没有答案