2011-12-23 2 views
1

그냥 궁금 :에서 iOS 5 후면 카메라 미리보기

I 카메라 미리보기를 표시하기위한 다양한 솔루션에서 찾아 봤는데; 전체 화면 모드에서 그렇게하는 것은 상대적으로 간단하지만, 화면의 50 %로 확대하여 그래픽 (오버레이는 아니지만 별도의 그래픽 동일한 공간을 차지하는 카메라 미리보기의 왼쪽). 기본적으로 사용자는 카메라 미리보기와 그래픽을 비교할 수 있습니다.

그래서, 내가 알아야 할 것은 : A) 오버레이 C 아닌 다른 그래픽과 아이 패드의 화면을 공유 할 수 있습니다) 낮은 해상도 B 카메라 미리보기를 확장 할 수 있습니다) a와 b가 참이라면, 내가 지적 해 줄 수있는 예제 소스가 있는가?

감사합니다.

previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:captureSession]; 
previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; 
previewLayer.opaque = YES; 
previewLayer.contentsScale = self.view.contentScaleFactor; 
previewLayer.frame = self.view.bounds; 
previewLayer.needsDisplayOnBoundsChange = YES; 
[self.view.layer addSublayer:previewLayer]; 

그냥 미리 층을 다른 프레임을 설정하는 5 호선을 대체 :

답변

0

당신은 다음 코드를 사용할 수 있습니다. 이 코드를 사용하여 captureSession을 만들 수 있습니다.

captureSession = [[AVCaptureSession alloc] init]; 

if(!captureSession) 
{ 
    NSLog(@"Failed to create video capture session"); 
    return NO; 
} 

[captureSession beginConfiguration]; 

captureSession.sessionPreset = AVCaptureSessionPreset640x480; 

AVCaptureDevice *videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; 
videoDevice.position = AVCaptureDevicePositionFront; 

if(!videoDevice) 
{ 
    NSLog(@"Couldn't create video capture device"); 
    [captureSession release]; 
    captureSession = nil; 
    return NO; 
} 

if([videoDevice isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus]) 
{ 
    NSError *deviceError = nil; 

    if([videoDevice lockForConfiguration:&deviceError]) 
    { 
     [videoDevice setFocusMode:AVCaptureFocusModeContinuousAutoFocus]; 
     [videoDevice unlockForConfiguration]; 
    } 
    else 
    { 
     NSLog(@"Couldn't lock device for configuration"); 
    } 
} 

NSError *error; 
AVCaptureDeviceInput *videoIn = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error]; 

if(!videoIn) 
{ 
    NSLog(@"Couldn't create video capture device input: %@ - %@", [error localizedDescription], [error localizedFailureReason]); 
    [captureSession release]; 
    captureSession = nil; 
    return NO; 
} 

if(![captureSession canAddInput:videoIn]) 
{ 
    NSLog(@"Couldn't add video capture device input"); 
    [captureSession release]; 
    captureSession = nil; 
    return NO; 
} 

[captureSession addInput:videoIn]; 
[captureSession commitConfiguration]; 
+0

제안 해 주셔서 감사합니다. –