2017-05-02 2 views
0

DidOutputSampleBuffer 대리자가 호출되지 않았지만 설치 카메라 코드에서 문제를 찾을 수 없습니다. github의 코드 : Demo codeAVCaptureVideoDataOutput 대리자가 호출되지 않았습니다.

내 세션에서 입력 출력을 인쇄하고 값이 있으며 미리 설정도되어 있습니다. 아무도 도와 줄 수 있습니까?

#import "DMVideoCamera.h" 
#import <UIKit/UIKit.h> 

@interface DMVideoCamera()<AVCaptureVideoDataOutputSampleBufferDelegate> 
@implementation DMVideoCamera 

- (instancetype)init { 
if (self = [super init]) { 
    [self setupCamera]; 
} 
return self; 
} 

- (void)setupCamera { 
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { 
    return; 
} 
if([self isAVCaptureActive]) { 
    _captureQueue = dispatch_queue_create("com.dmall.ScanQueue", DISPATCH_QUEUE_SERIAL); 
    NSError *error = nil; 
    _device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; 

    _session = [[AVCaptureSession alloc] init]; 
    [self configSessionPreset]; 

    _output = [[AVCaptureVideoDataOutput alloc] init]; 
    [_output setVideoSettings:@{ 
           (NSString *)kCVPixelBufferPixelFormatTypeKey : [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA] 
           }]; 
    [_output setAlwaysDiscardsLateVideoFrames:YES]; 
    [_output setSampleBufferDelegate:self queue:_captureQueue]; 

    _input = [AVCaptureDeviceInput deviceInputWithDevice:_device error:&error]; 
    if ([_session canAddInput:_input]) { 
     [_session addInput:_input]; 
    } 
    if ([_session canAddOutput:_output]) { 
     [_session addOutput:_output]; 
    } 

} 
else { 
    [self showAccessAlert]; 
} 
} 

그리고의 ViewController에서

, 나는 다음과 같이 설정합니다 Demo code : 프로젝트를 실행하려면, 내 GitHub의에서 코드를 다운로드하시기 바랍니다

- (void)viewDidLoad { 
[super viewDidLoad]; 
DMVideoCamera *camera = [DMVideoCamera new]; 
AVCaptureVideoPreviewLayer *previewLayer =[AVCaptureVideoPreviewLayer layerWithSession:camera.session]; 
previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; 
previewLayer.frame = self.view.bounds; 
[self.view.layer addSublayer:previewLayer]; 
camera.zoomFactor = 1.6; 
[camera start]; 
} 

.

대단히 감사합니다.

답변