2011-06-11 1 views
9

AVFoundation 및 ImageIO 구현을 통해 내 응용 프로그램에서 사진을 처리했습니다. 나는 그것에 문제가있다. 플래시가 꺼지더라도 찍은 이미지는 항상 어둡습니다. 다음은 내가 사용하는 코드입니다.AVCaptureOutput은 플래시 사용시에도 어두운 사진을 촬영합니다.

 [[self currentCaptureOutput] captureStillImageAsynchronouslyFromConnection:[[self currentCaptureOutput].connections lastObject] 
             completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) { 

              [[[blockSelf currentPreviewLayer] session] stopRunning]; 
              if (!error) { 
               NSData *data   = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer]; 
               CGImageSourceRef source = CGImageSourceCreateWithData((CFDataRef) data, NULL); 

               if (source) { 

                UIImage *image = [blockSelf imageWithSource:source]; 
                [blockSelf updateWithCapturedImage:image]; 
                CFRelease(source); 

               } 

              } 

             }]; 

이미지에 플래시가 포함되지 않았습니까?

답변

14

이 호출 바로 전에 AVCaptureSession이 설정된 경우 때때로 어두운 이미지가 나타납니다. 아마도 자동 노출 & 화이트 밸런스 설정이 스스로 조정할 때까지 어느 정도 시간이 걸릴 것입니다. AVCaptureDevice의 adjustingExposureadjustingWhiteBalance 속성 -[AVCaptureStillImageOutput captureStillImageAsynchronouslyFromConnection: completionHandler:]를 호출하기 전에 모두 NO (KVO 이러한 관찰을) 때까지

솔루션

는 그 다음 AVCaptureSession을 설정 기다려야했다.

+1

어떻게 할 수 있습니까? adjustmentExposure와 adjustmentWhiteBalance를 모두 관찰하면 captureStillImageAsynchronouslyFromConnection을 정확히 호출해야합니까? 스트레이트 from observeValueForKeyPath? – grzaks

+0

그 방법을 찾았습니까? 왜냐하면 나는 지금 내 아이폰 6에서 똑같은 문제를 겪고 있기 때문이다. – Sebastien