Tag: avcapturesession

从iPhone摄像头(AVCaptureSession)捕获24 bpp位图中的图像

我使用AVCaptureSession从iPhone的前置摄像头捕获帧。 我试图改变AVCaptureVideoDataOutput的格式,以便它可以捕获一个24 bpp的位图。 这段代码为我提供了一个没有任何问题的32 bpp位图: AVCaptureVideoDataOutput *outputDevice = [[AVCaptureVideoDataOutput alloc] init]; outputDevice.videoSettings = [NSDictionary dictionaryWithObject: [NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey: (id)kCVPixelBufferPixelFormatTypeKey]; [outputDevice setSampleBufferDelegate:self queue:dispatch_get_main_queue()]; 但是,当我将其更改为24时,会在该行上崩溃。 outputDevice.videoSettings = [NSDictionary dictionaryWithObject: [NSNumber numberWithInt:kCVPixelFormatType_24RGB] forKey: (id)kCVPixelBufferPixelFormatTypeKey]; 我怎样才能在24 bpp中捕捉图像? 为什么它失败* kCVPixelFormatType_24RGB *? 解决方法是将32 bmp转换为24,但我还没有find如何做到这一点。

如何使用AVCaptureDeviceFormat从iPhone录制timelapsevideo?

我试图通过iPhone录制一个timelapsevideo。 我已经得到它慢动作的工作(通过捕捉最大帧可能),120帧/秒。 现在我正试图颠倒逻辑来捕捉尽可能less的帧,以实现timelapsefunction。 代码stream是这样的: 从AVCaptureDevice的可用设备格式查询所有支持的帧范围。 检查帧速率是否低于或等于所需的20 fps,尺寸等于或大于1920 * 1080。 所有工作正常,除了当我按下logging,我得到"AVCaptureMovieFileOutput – no active/enabled connections"例外。 我只使用提供的帧速率和范围之一,为什么我得到这个exception? 所有的效果为30帧/秒。 #define kTimelapseRequiredFPS = 20 #define kMinRequiredDimensions (1920*1080) – (void)configureCameraForSlowMoRecording:(AVCaptureDevice *)currentCaptureDevice { [_captureSession beginConfiguration]; AVCaptureDeviceFormat *bestFormat = nil; AVFrameRateRange *bestFrameRateRange = nil; for ( AVCaptureDeviceFormat *format in [currentCaptureDevice formats] ) { //NSLog(@"Format: %@", format); CMFormatDescriptionRef videoInfo = [format formatDescription]; double […]

CaptureStillImageAsynchronouslyFromConnection用于后置摄像头

let VideoDevice = CameraWithPosition(AVCaptureDevicePosition.Back) // not working let VideoDevice = CameraWithPosition(AVCaptureDevicePosition.Front) // working if let stillOutput = self.stillImageOutput { if let videoConnection = stillOutput.connectionWithMediaType(AVMediaTypeVideo) { println("stillOutput \(stillOutput)") stillOutput.captureStillImageAsynchronouslyFromConnection(videoConnection){ (imageSampleBuffer : CMSampleBuffer!, _) in println("imageSampleBuffer \(imageSampleBuffer)") //prints nil for back camera, works for front camera …more code 我能够从前置摄像头捕获图像,但同样的过程不适用于我的iPhone的后置摄像头,这两个摄像头是否有任何不同的设置? 接收imageSampleBuffer作为返回相机的零。 错误日志: 错误域= AVFoundationErrorDomain代码= -11800“操作无法完成”UserInfo = 0x1704682c0 {NSUnderlyingError […]

从后台返回后的AVCapturesession处理

我正在使用AVCaptureSession实现VideoRecorder。 我开始AVCaptureSession在viewWillAppear并撕毁在viewWillDisappear这个问题的build议AVCaptureSession从后台返回时失败 。 现在当video是录音和应用程序去背景我想停止录制和暂停捕捉会议。 但是,每次应用程序在这一点上前景,我会得到以下一个 捕获会话没有暂停,但录制和预览层不断更新 捕获会话提供黑屏的预览层在这一点上的应用程序可能会或可能不会崩溃。 在这一点上处理AVCaptureSession的任何build议。 我想只显示logging在previewLayer上的最后一帧,一旦录制停止。

AVCaptureSession VS UIImagePickerController相机预览

我正在开发一个类似于Instagram iOS应用程序的应用程序。 Instagram有一个自定义相机预览。 我想开发类似的东西,问题是 – 什么更好的用于这个目的 – 具有自定义cameraOverlayView属性的UIImagePickerController还是应该使用AVCaptureSession? 也许有人有这样的经验,可以给我一个build议。 将不胜感激。

使用AVCaptureSession录制video时,音乐应用程序(在后台播放)会中断

我正在开发像应用程序一样的function。 在我的应用程序中,音乐应用程序在后台运行,我的应用程序处于前台状态。 我必须同时在后台运行音乐应用程序捕捉video。 问题: – 当我的应用程序进入前台状态,音乐应用程序audio暂停一秒钟,然后继续。 同样的问题出现时,用户点击HOMEbutton,应用程序进入后台状态和音乐应用程序audiorest一秒钟。 我已经下载了用于录制的苹果示例代码https://developer.apple.com/library/ios/samplecode/AVCam/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010112 下载后,在AppDelegate中完成了以下更改 在AppDelegate.h中 导入AVFoundation @property(nonatomic,retain)AVAudioSession * session1; 在AppDelegate.m中 self.session1 = [AVAudioSession sharedInstance]; [self.session1 setCategory:AVAudioSessionCategoryAmbient withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker | AVAudioSessionCategoryOptionMixWithOthers | AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers error:nil]; [self.session1 setActive:YES error:nil]; // Inform the device that we want to use the device orientation. [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 在AAPLCameraViewController.m中 两个属性已被添加 self.session.usesApplicationAudioSession = TRUE; self.session.automaticallyConfiguresApplicationAudioSession = FALSE; 其他方式 我已经尝试使用SCRecorder库,但同样的问题是与该库。 […]

用AVCaptureSession在iOS上读取QRCodes – alignment问题?

我们在iOS中使用AVCaptureSession类实现了QRCode读取function,如下所述: https://github.com/HEmobile/ScanBarCode/tree/master/ScanBarCodes https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVCaptureSession_Class/ 但是我们注意到一件事… QRCode必须完全垂直或水平alignment。 诸如45度的倾斜angular度不会触发扫描。 这个问题真的不是谷歌,这是令人惊讶的。 我们的其他QR码阅读应用程序的实验表明,这种限制不存在。 也许/看起来(可能 – 因为内置函数是新的)这些应用程序不使用AVCaptureSession。 我们的问题是,这是一个标志,苹果的这个function的版本还不成熟吗? 还是有一些选项来启用或改善这种能力? 感谢您的任何想法。

AVCaptureStillImageOutput区域select

在用Swift编写的iOS应用程序中保存从相机拍摄的图像时,这是我面临的挑战。 我并不是完全按照自己的意愿去储蓄,而是在储蓄之外,而不是那么做。 这是这个问题的两个相关的代码块。 首先在会议开始的地方,人们可以看到我只看着一个椭圆形区域: previewLayer = AVCaptureVideoPreviewLayer(session: captureSession) previewLayer?.frame = self.view.layer.frame self.view.layer.addSublayer(previewLayer!) let maskLayer = CAShapeLayer() maskLayer.path = CGPathCreateWithEllipseInRect(CGRect(x: 50.0, y: 100.0, width: 200.0, height: 100.0), nil) previewLayer!.mask = maskLayer captureSession.startRunning() 第二,保存图像并停止会话: if captureSession.running { if let videoConnection = stillImageOutput.connectionWithMediaType(AVMediaTypeVideo) { stillImageOutput.captureStillImageAsynchronouslyFromConnection(videoConnection) { (imageDataSampleBuffer, error) -> Void in if error == nil { let imageData […]

AVCaptureSession addInput问题与ios8

我有一个AVCaptureSession的应用程序与以前的iOS版本正常工作,但后来我试着运行与ios8,应用程序坠毁零星的设备上。 但问题没有解决。 例外进入“[会话addInput:input];” 。 请咨询如何解决。 请validation我的下面的代码,并得到错误在[会话addInput:input]; 打印错误描述:Error Domain = AVFoundationErrorDomain Code = -11852“不能使用后退摄像头”UserInfo = 0x17c076e0 {NSLocalizedDescription =不能使用后退摄像头,AVErrorDeviceKey =,NSLocalizedFailureReason =这个程序没有被授权使用后视镜。 #import "CameraViewController.h" #import "MAImagePickerControllerAdjustViewController.h" #import "PopupViewController.h" #import "MAImagePickerFinalViewController.h" @implementation CameraViewController @synthesize vImagePreview; @synthesize vImage; @synthesize stillImageOutput; @synthesize lFrameCount; @synthesize session; @synthesize device; @synthesize oneOff; @synthesize captureManager = _captureManager; @synthesize flashButton = _flashButton; @synthesize vImage1; @synthesize vImage2; […]

AVCam保存全屏捕获的图像

我正在使用苹果公司生产的AVCam来定制相机视图。 老实说,如果你第一次看到AVCamViewController类,那么理解AVCamViewController是怎么回事呢? 现在我感兴趣的是他们如何设置捕获图像的帧。 我试图find一些名人或类似的东西,但我还没有find。 我在谷歌search,并find答案在这里AVCam不全屏 但是当我实现这个解决scheme时,我只是意识到它只是制作了与我的视图相同大小的实时相机预览图层,但是当应用程序将图像保存在方法中时- (IBAction)snapStillImage:(id)sender从左边和右边2条。 我的问题是如何删除这个条纹或在源代码中的哪一行苹果设置这个东西? 另外作为附加的子问题,我怎样才能设置types创build照片,因为应用程序要求我“麦克风设置”,我不需要它只是需要照片,就是这样。 这个苹果来源的代码将图像保存到照片库。 – (IBAction)snapStillImage:(id)sender { dispatch_async([self sessionQueue], ^{ // Update the orientation on the still image output video connection before capturing. [[[self stillImageOutput] connectionWithMediaType:AVMediaTypeVideo] setVideoOrientation:[[(AVCaptureVideoPreviewLayer *)[[self previewView] layer] connection] videoOrientation]]; // Flash set to Auto for Still Capture [AVCamViewController setFlashMode:AVCaptureFlashModeAuto forDevice:[[self videoDeviceInput] device]]; // Capture a still […]