未调用DidOutputSampleBuffer委托,但我在设置摄像头代码中找不到任何问题。 github中的代码:Demo code
我在会话中打印输入输出,它们有值,并且还设置了预设,有人可以帮助我吗?
Function.prototype.method = function(name, func) {
this.prototype[name] = func;
return this;
};
在viewController中,我设置如下:
#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];
}
}
如果您想运行该项目,请从我的github下载代码:Demo code。
非常感谢!
答案 0 :(得分:0)
我解决了这个问题,只需将设置更改为一些get方法,它就可以在我的Github中使用:https://github.com/dulingkang/DMScanCode