2013-06-26 55 views
2

我使用gpuimage來構建一個攝影應用程序。但是,當我選擇了前置攝像頭,攝像頭的畫面出現在背部反轉(左,右) 代碼在這裏:反轉的倒視時間相機被倒轉

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]; 

誰能告訴我,我有什麼樣的問題? 非常感謝!

回答

5

試試這個...

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]; 
+0

感謝Dhara,但我並沒有找到水平的MirrorFrontFacingCamera和水平的MirrorRearFacingCamera。 – bachle26

0

我認爲你可以很容易地改變最終圖像:

UIImage *finalImage = //image from the camera 

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

試試這個:

[filterView setInputRotation:kGPUImageFlipHorizonal atIndex:0]; 
+0

謝謝七!我已經完成了 – bachle26

+0

謝謝老兄!它完美的工作! :D – Lapinou

+1

我找到了一個我建議使用的屬性。因爲如果您使用此方法切換前/後相機,則還必須更改setInputRotation。所以,爲了減少你的代碼,你可以將這段代碼添加到你的相機對象(GPUImageVideoCamera)中:_stillCamera.horizo​​ntallyMirrorFrontFacingCamera = YES; – Lapinou

0

只需設置:

stillCamera.horizontallyMirrorFrontFacingCamera = YES; 

將解決這個問題。