Add more camera customization options
artemkalinovsky opened this issue · comments
Hi all,
Thanks for awesome CameraManager.
I have idea to add more customization for video and audio settings.
For example, add ability to set capturing area for camera.
Here some code, that express it:
-for video
videoOutput!.videoSettings = [kCVPixelBufferPixelFormatTypeKey: Int(kCVPixelFormatType_32BGRA), AVVideoWidthKey : 100, AVVideoHeightKey: 100]
videoOutput!.setSampleBufferDelegate(self, queue: dispatch_queue_create("sample buffer delegate", DISPATCH_QUEUE_SERIAL))
if captureSession!.canAddOutput(self.videoOutput) {
captureSession!.addOutput(self.videoOutput)
}
-for photo
fileprivate func _applyPreviewLayerBounds(capturedImage image: UIImage) -> UIImage? {
guard let previewLayer = previewLayer,
let cgImage = image.cgImage else {
return nil
}
let rect = previewLayer.metadataOutputRectOfInterest(for: previewLayer.bounds)
let width = CGFloat(cgImage.width)
let height = CGFloat(cgImage.height)
let cropRect = CGRect(x: rect.origin.x * width,
y: rect.origin.y * height,
width: rect.size.width * width,
height: rect.size.height * height)
guard let img = cgImage.cropping(to: cropRect) else {
return nil
}
return UIImage(cgImage: img, scale: 1.0, orientation: image.imageOrientation)
}
What do you think?
Thanks
@artemkalinovsky we think that this is out of scope for now
but thanks for the idea @artemkalinovsky :)