Custom Camera View! (Swift 2 in Xcode)
Why Stack Overflow recommends it
Stack Overflow users cite it as the starting point for their own AVFoundation camera code, usually when they run into Swift 3 changes or want to adapt it to record video or scan codes.
Recommended by 1 people across 1 different months, 2016 to 2017.
What it is
A Swift 2 tutorial in Xcode by Jared Davidson (archetapp) that walks through building a custom camera view with AVFoundation, including a live preview layer and photo capture. The description notes that Swift 3 changed the syntax but the underlying logic is the same.
What people said
Recommends mcd · 2016-12 · Stack Overflow · on “Create camera overlay for read QR code”
Maybe these tutorials will help you: [this video] App Coda Tutorial about how to create a barcode reader app (contains information about AVFoundation) [LINK] The AV Foundation Framework provides the tools that we will use to build our barcode reader. Here’s a little rundown of what’s involved in the process. AVCaptureSession will manage data form the camera – input to output. The AVCaptureDevice is the physical device and its properties. AVCaptureSession receives input data from the AVCaptureDevice . AVCaptureDeviceInput captures data from the input device. AVCaptureMetadataOutput forwards metadata objects to be processed by a delegate object. Maybe this will help: How to add a blur mask with a c
Cites Kervon Ryan · 2016-09 · Stack Overflow · on “Save Video Using AVFoundation Swift”
Hi I followed a course by Jared Davidson to create a custom camera view and save pictures using AVFoundation. [this video] However I would like to record and save videos instead of images. Can someone help me here? I'm sure its simple but apple's Documentation is written in Objective-C and I cant decipher it. This is my code. Thanks. import UIKit import AVFoundation class ViewController: UIViewController { var captureSession = AVCaptureSession() var sessionOutput = AVCaptureStillImageOutput() var previewLayer = AVCaptureVideoPreviewLayer() @IBOutlet var cameraView: UIView! override func viewWillAppear(animated: Bool) { let devices = AVCaptureDevice.devicesWithMediaType(AVMediaTypeVideo) for devic
Cites Jeff Huang · 2016-10 · Stack Overflow · on “Swift 3 - AVCapture custom camera view”
I was following through this video to make a custom camera view. [this video] however due to iOS 10 and swift 3 changes many things weren't relevant anymore the following is the code I got out after changing deprecated function to the new ones..however there is no error, but also not seeing a preview on the UIView import UIKit import AVFoundation class ViewController: UIViewController, AVCapturePhotoCaptureDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate { @IBOutlet weak var cameraView: UIView! var captureSession = AVCaptureSession(); var sessionOutput = AVCapturePhotoOutput(); var sessionOutputSetting = AVCapturePhotoSettings(format: [AVVideoCodecKey:AVVideoCodecJPEG]);
Cites ZiEiTiA · 2017-01 · Stack Overflow · on “AVFoundation to take video swift 3”
I have been following this tutorial: [this video] and managed to get to the point where I can take photos, and see the camera output on my UIView. However I need to record video instead of taking photos. I have looked on stackOverflow and in the AVFoundation help, but couldn't get it to work. This is my code so far: override func viewDidAppear(_ animated: Bool) { let devices = AVCaptureDevice.devices() for device in devices! { if (device as AnyObject).position == AVCaptureDevicePosition.back { do { let input = try AVCaptureDeviceInput(device: device as! AVCaptureDevice) if captureSession.canAddInput(input) { captureSession.addInput(input) if captureSession.canAddOutput(sessionOutput) { captureSes