Skip to main content

Usage & Interface

1. Launch the Lens camera:
VeryfiLens.shared().showCamera(in: self)
2. Optionally, instead of launching the Lens camera experience, you may perform one of the following:
  • Launch the Gallery screen to submit images from the Photo Gallery:
VeryfiLens.shared().showGallery(in: self)
  • Launch the Files Browser screen to submit documents:
VeryfiLens.shared().showDocumentBrowser(in: self)
  • Retry uploading specific package:
VeryfiLens.shared().utils.retryPackage(with: packageId)
  • Retry uploading all packages currently in queue
VeryfiLens.shared().utils.retryAllPackages()
  • Remove specific package from the queue
VeryfiLens.shared().utils.discardPackage(with: packageId)
  • Remove all packages from the queue
VeryfiLens.shared().utils.discardAllPackages()
  • Share OCR feedback for last scan
VeryfiLens.shared().shareOCRFeedback()
1. Manage the Lens experience:
  • Enable buffer processing which starts detection of documents
VeryfiLensHeadless.shared().startProcessingBuffer()
  • Process a frame buffer to see if there's any document
VeryfiLensHeadless.shared().processWithBlock(buffer: frame) { rectangles, buffer in
// Call adjustedRectangles like this to change corner values that you can use on your camera view to draw
let convertedRectangles = VeryfiLensHeadless.shared().adjustedRectangles(
rectangles,
for: buffer,
videoPreviewLayer: cameraView.previewLayer // set your camera previwLayer
)
// Draw some borders with the rectangles object
}
  • Disable buffer processing which stops/pauses detection of documents
VeryfiLensHeadless.shared().stopProcessingBuffer()
  • Returns adjusted corners of detected documents in camera (intended for those who want to draw over those coordinates)
VeryfiLensHeadless.shared().adjustedRectangles(
_ rectangles: [RectangleFeature],
for buffer: CMSampleBuffer,
videoPreviewLayer: AVCaptureVideoPreviewLayer) -> [RectangleFeature]
  • Reset lens state
VeryfiLensHeadless.shared().reset()
  • Close lens (Call this whenever you want to reset the autocapture process after document detection)
VeryfiLensHeadless.shared().close()
2. Optionally, you may use the following at your convenience:
  • Crop image (this method will return an empty [UIImage] array if no suitable corners where found to crop aka. no document detected)
VeryfiLensHeadless.shared().crop(image: rotatedImage) { [weak self] croppedImages in
// Use the croppedImages UIImage array
}
  • Rotate image
VeryfiLensHeadless.shared().rotate(image: UIImage) -> UIImage
  • Upload images
VeryfiLensHeadless.shared().upload(images: [UIImage])
  • Uploads a document without UI
VeryfiLensHeadless.shared().upload(url: URL)
  • Update lens settings
VeryfiLensHeadless.shared().updateSettings(_ settings: VeryfiLensHeadlessReceipts.VeryfiLensHeadlessSettings)
3. For all of the above features, your app will need to communicate with Lens to handle user actions, various status changes and extraction results from Veryfi. See the Communicating with Lens section below for details