I use the below function to display a live camera view onto an iPhone screen.
Does anyone know how I can apply a core image filter to it, such as comic, or sepia, etc?
func showCameraVC() {
self.myLiveCameraView = UIImagePickerController()
if UIImagePickerController.isCameraDeviceAvailable(.front) {
self.myLiveCameraView?.sourceType = .camera
self.myLiveCameraView?.cameraDevice = .front
self.myLiveCameraView?.showsCameraControls = false
let screenSize = UIScreen.main.bounds.size
let cameraAspectRatio = CGFloat(4.0 / 3.0)
let cameraImageHeight = screenSize.width * cameraAspectRatio
let scale = screenSize.height / cameraImageHeight
self.myLiveCameraView?.cameraViewTransform = CGAffineTransform(translationX: 0, y: (screenSize.height - cameraImageHeight)/2)
self.myLiveCameraView?.cameraViewTransform = self.myLiveCameraView!.cameraViewTransform.scaledBy(x: scale, y: scale)
self.myLiveCameraView?.view.frame = CGRect(x: 0, y: 0, width: screenSize.width / 2, height: screenSize.height / 2)
self.view.addSubview(self.myLiveCameraView!.view)
self.myLiveCameraView!.view.layer.borderColor = UIColor.blue.cgColor
self.myLiveCameraView!.view.layer.borderWidth = 0
self.myLiveCameraView!.view.clipsToBounds = true
}
} // ends showCameraVC