2014-02-06 1 views
2

저는 AutoFocus, AutoExposure, AutoWhiteBalance 및 LowLightBoost를 사용했지만 네이티브 iPhone 5 카메라를 사용하여 보거나 캡처 한 것만 큼 밝게 표시되도록 카메라 이미지를 얻을 수 있습니다.AVFoundation 카메라 이미지를 네이티브 카메라로 촬영 한 것과 같이 밝게 만드는 방법은 무엇입니까?

내가 잘못하고 있는지 확실하지 않습니다. 다음은 화면을 누를 때 자동 카메라 기능을 설정하는 주요 기능입니다. 자동 초점이 작동합니다. 그러나 자동 노출, 화이트 밸런스 및 LowLightBoost가 정상적으로 작동하는지 여부는 확인해야합니다. 어두운 항목은 원래 카메라와 함께 밝게 빛나지 않기 때문입니다. 아래 코드의 대부분은 iosDev Center Site에 게시 된 AVCam 예제에서 가져온 것입니다.

미리 감사드립니다.

- (IBAction)focusAndExposeTap:(UIGestureRecognizer *)gestureRecognizer 
{ 
    CGPoint devicePoint = [(AVCaptureVideoPreviewLayer *)[[self previewView] layer] captureDevicePointOfInterestForPoint:[gestureRecognizer locationInView:[gestureRecognizer view]]]; 
    [self focusWithMode:AVCaptureFocusModeAutoFocus exposeWithMode:AVCaptureExposureModeAutoExpose whiteBalanceWithMode:AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance atDevicePoint:devicePoint monitorSubjectAreaChange:YES]; 
} 

- (void)focusWithMode:(AVCaptureFocusMode)focusMode exposeWithMode:(AVCaptureExposureMode)exposureMode whiteBalanceWithMode:(AVCaptureWhiteBalanceMode)whiteBalanceMode atDevicePoint:(CGPoint)point monitorSubjectAreaChange:(BOOL)monitorSubjectAreaChange{ 
dispatch_async([self sessionQueue], ^{ 
    AVCaptureDevice *device = [[self videoDeviceInput] device]; 
    NSError *error = nil; 
    if ([device lockForConfiguration:&error]) 
    { 
     if ([device isFocusPointOfInterestSupported] && [device isFocusModeSupported:focusMode]) 
     { 
      [device setFocusMode:focusMode]; 
      [device setFocusPointOfInterest:point]; 
     } 
     NSLog(@"Pre-Exposure Mode Support?: %hhd", [device isExposurePointOfInterestSupported]); 
     if ([device isExposurePointOfInterestSupported] && [device isExposureModeSupported:exposureMode]) 
     { 
      [device setExposureMode:exposureMode]; 
      [device setExposurePointOfInterest:point]; 
     } 
     NSLog(@"Pre-White Balance mode Support? %hhd", [device isWhiteBalanceModeSupported:whiteBalanceMode]); 
     if ([device isWhiteBalanceModeSupported:whiteBalanceMode]) 
     { 
      [device setWhiteBalanceMode:whiteBalanceMode]; 
     } 
     NSLog(@"Pre Low light mode: %hhd", [device isLowLightBoostSupported]); 
     if ([device isLowLightBoostSupported]){ 
      [device setAutomaticallyEnablesLowLightBoostWhenAvailable:YES]; 
     } 
     [device setSubjectAreaChangeMonitoringEnabled:monitorSubjectAreaChange]; 
     [device unlockForConfiguration]; 
    } 
    else 
    { 
     NSLog(@"%@", error); 
    } 
}); 
} 
+0

당신이 해결책을 찾을 수있었습니다을 upvote에 있고,이 문제가 해결되지 않을 경우 알려 주시기 바랍니다? – amone

답변

0

제 생각에 문제는 AVCaptureExposureMode에 있습니다. 내 스레드 here에서 참조 할 수 있으므로 iOS 7은 현재 모든 기기에서 AVCaptureExposureModeAutoExpose을 지원하지 않습니다. 따라서 exposurePointOfInterest은 원하는 지점에 설정되지 않습니다.

심지어 코드를 당신의 다음 코드를 입력하지 않습니다 귀하의 프로그램 (사용자가 직접 확인할 수 있습니다) :

if ([device isExposurePointOfInterestSupported] && [device isExposureModeSupported:exposureMode]) 
     { 
      [device setExposureMode:exposureMode]; 
      [device setExposurePointOfInterest:point]; 
     } 

당신이 자동 기능을 노출 갖고 싶어, 당신이에 노출을 설정 AVCaptureExposureModeContinuousAutoExpose을 사용 할 수 있습니다 어떤 점. 그런 다음 isAdjustingExposure 속성이 AVCaptureDevice 인 키 - 값 관찰 (KVO)을 듣고 조정이 완료되면 알려줍니다. 설정이 끝나자 마자으로 설정하십시오.

그렇지 않으면 당신은 동의하고이 대답 :