简体   繁体   中英

Reverse facetime camera is inverted

I use gpuimage to build a photography app. But when I select the front camera, the camera picture appears on the back is reversed (left, right) Code here:

 stillCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack]; 
stillCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
filter = [[GPUImageRGBFilter alloc] init];

[stillCamera addTarget:filter];
GPUImageView *filterView = (GPUImageView *)self.view;
[filter addTarget:filterView];

[stillCamera startCameraCapture];

Who can tell me what I'm having problems? Thank very much!

try this...

stillCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack]; 
stillCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
stillCamera.horizontallyMirrorFrontFacingCamera = NO;
stillCamera.horizontallyMirrorRearFacingCamera = NO;

filter = [[GPUImageRGBFilter alloc] init];

[stillCamera addTarget:filter];
GPUImageView *filterView = (GPUImageView *)self.view;
[filter addTarget:filterView];

[stillCamera startCameraCapture];

尝试这个 :

[filterView setInputRotation:kGPUImageFlipHorizonal atIndex:0];

I think that you can easily change the final image :

UIImage *finalImage = //image from the camera

UIImage * flippedImage = [UIImage imageWithCGImage:finalImage.CGImage scale:finalImage.scale orientation:UIImageOrientationLeftMirrored];

Just set:

stillCamera.horizontallyMirrorFrontFacingCamera = YES;

will fix this problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM