avcapturedevice

Get Camera Preview to AVCaptureVideoPreviewLayer

我只是一个虾纸丫 提交于 2019-11-28 23:43:58
I was trying to get the camera input to show on a preview layer view. self.cameraPreviewView is tied to a UIView in IB Here is my current code that I put together from the AV Foundation Programming Guide. But the preview never shows AVCaptureSession *session = [[AVCaptureSession alloc] init]; session.sessionPreset = AVCaptureSessionPresetHigh; AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; NSError *error = nil; AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error]; if (!input) { NSLog(@"Couldn't create video

How to get front camera, back camera and audio with AVCaptureDeviceDiscoverySession

纵然是瞬间 提交于 2019-11-28 16:50:34
Before iOS 10 came out I was using the following code to get the video and audio capture for my video recorder: for device in AVCaptureDevice.devices() { if (device as AnyObject).hasMediaType( AVMediaTypeAudio ) { self.audioCapture = device as? AVCaptureDevice } else if (device as AnyObject).hasMediaType( AVMediaTypeVideo ) { if (device as AnyObject).position == AVCaptureDevicePosition.back { self.backCameraVideoCapture = device as? AVCaptureDevice } else { self.frontCameraVideoCapture = device as? AVCaptureDevice } } } When iOS 10 finally came out, I received the following warning when I was

Why AVCaptureSession output a wrong orientation?

自作多情 提交于 2019-11-28 16:05:15
So, I followed Apple's instructions to capture video session using AVCaptureSession : http://developer.apple.com/iphone/library/qa/qa2010/qa1702.html . One problem I'm facing is that even though the orientation of the camera / iPhone device is vertical (and the AVCaptureVideoPreviewLayer shows a vertical camera stream), the output image seems to be in the landscape mode. I checked the width and height of imageBuffer inside imageFromSampleBuffer: of the sample code, and I got 640px and 480px respectively. Does anyone know why this's the case? Thanks! Jon Steinmetz Take a look at the header

Why does AVCaptureVideoOrientation landscape modes result in upside down still images?

孤者浪人 提交于 2019-11-28 07:49:32
I am using AVFoundation classes to implement a custom camera in my app. I am only capturing still images, not video. I have everything working but am stumped by something. I take into account the device orientation when a still image is captured and set the videoOrientation of the video connection appropriately. A code snippet: // set the videoOrientation based on the device orientation to // ensure the pic is right side up for all orientations AVCaptureVideoOrientation videoOrientation; switch ([UIDevice currentDevice].orientation) { case UIDeviceOrientationLandscapeLeft: // Not clear why but

Set GrayScale on Output of AVCaptureDevice in iOS

此生再无相见时 提交于 2019-11-27 23:58:28
问题 I want to implement custom camera into my app. So, I am creating this camera using AVCaptureDevice . Now I want to show only Gray Output into my custom camera. So I am trying to getting this using setWhiteBalanceModeLockedWithDeviceWhiteBalanceGains: and AVCaptureWhiteBalanceGains . I am using AVCamManual: Extending AVCam to Use Manual Capture for this. - (void)setWhiteBalanceGains:(AVCaptureWhiteBalanceGains)gains { NSError *error = nil; if ( [videoDevice lockForConfiguration:&error] ) {

AVCaptureVideoPreviewLayer (camera preview) freezes/stuck after moving to background and back

一个人想着一个人 提交于 2019-11-27 17:24:52
问题 Cant figure this one out. Everything works fine when the app is active, and than sometimes when i move the app to the background(pressing the home button) and than going back, the previewlayer freezes/stuck. Im using viewWillAppear and viewDidAppear for the set up. This is how i set everything up : var backCamera = AVCaptureDevice.devicesWithMediaType(AVMediaTypeVideo) var global_device : AVCaptureDevice! var captureSession: AVCaptureSession? override func viewWillAppear(animated: Bool) {

How to get front camera, back camera and audio with AVCaptureDeviceDiscoverySession

家住魔仙堡 提交于 2019-11-27 09:59:01
问题 Before iOS 10 came out I was using the following code to get the video and audio capture for my video recorder: for device in AVCaptureDevice.devices() { if (device as AnyObject).hasMediaType( AVMediaTypeAudio ) { self.audioCapture = device as? AVCaptureDevice } else if (device as AnyObject).hasMediaType( AVMediaTypeVideo ) { if (device as AnyObject).position == AVCaptureDevicePosition.back { self.backCameraVideoCapture = device as? AVCaptureDevice } else { self.frontCameraVideoCapture =

Why does AVCaptureVideoOrientation landscape modes result in upside down still images?

被刻印的时光 ゝ 提交于 2019-11-27 01:59:24
问题 I am using AVFoundation classes to implement a custom camera in my app. I am only capturing still images, not video. I have everything working but am stumped by something. I take into account the device orientation when a still image is captured and set the videoOrientation of the video connection appropriately. A code snippet: // set the videoOrientation based on the device orientation to // ensure the pic is right side up for all orientations AVCaptureVideoOrientation videoOrientation;

AVCaptureSession and background audio iOS 7

拟墨画扇 提交于 2019-11-27 01:09:36
Whenever I start an AVCaptureSession running with the microphone as an input it cancels whatever background music is currently running (iPod music for instance). If I comment out the line adding the audio input, the background audio continues. Does anyone know a way to record video clips with the microphone while continuing to allow background audio to play? Also there is error, when you trying to record video and the music is currently playing. A tried to do like this: [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: nil]; UInt32 doSetProperty = 1;

Accessing iOS 6 new APIs for camera exposure and shutter speed

為{幸葍}努か 提交于 2019-11-27 00:29:00
On Apple's iOS 6.0 feature page , it used to say Take advantage of the built-in camera’s advanced features. New APIs let you control focus, exposure, and region of interest. You can also access and display faces with face detection APIs, and leverage hardware-enabled video stabilization. This text has since been removed, and I can't find new methods in the API for controlling exposure. In class AVCaptureDevice under "Exposure Settings" there is no new property/method for iOS 6.0. Do you know where i can find new features for exposure in API? It's true that there is an -exposureMode property on