I'm creating an app that has a live scan feature. I added the following code to present the view controller that shows what the document camera sees when a button is clicked
let documentCameraViewController = VNDocumentCameraViewController()
documentCameraViewController.delegate = self
present(documentCameraViewController, animated: true)
It is working, but the only issue is the auto shutter is by default set to ON, and it keeps taking scans until I click save. I can manually set the auto shutter to Off, but I don't want that. I want that the auto shutter for the first scan to be on, and then it doesn't keep taking any more photos automatically (the auto shutter switches to off). Is there any way I could do that? if not, how can I set the default auto shutter to off?
Thank you!
CodePudding user response:
You can't. Also delegate will receive all the scans at once.
The closest alternative is to dismiss VNDocumentCameraViewController
and take the first scan inside documentCameraViewController: didFinishWith
, as shown here for example:
func documentCameraViewController(_ controller: VNDocumentCameraViewController, didFinishWith scan: VNDocumentCameraScan) {
documentCameraViewController?.dismiss(animated: true, completion: nil)
documentCameraViewController = nil
// ...
let firstImage = scan.imageOfPage(at: 0)
However VNDocumentCameraViewController
is there to provide a basic functionality. So if you need anything more fine-tuned, it's more common to build a custom camera and process frames with the Vision framework