Aila_ID1CaptureImage
Captures images of ID-1 sized cards.
Signature
- Objective-C
- Swift
void Aila_ID1CaptureImage(void (^completion)(UIImage *image, NSError *error));
func Aila_ID1CaptureImage(_ completion: @escaping (UIImage?, Error?) -> Void)
Parameters
completion- Block/closure called when capture completes
Description
Captures images of ID-1 sized cards (e.g., credit cards, driver's licenses, health insurance cards) when using Aila's Interactive Kiosk equipped with the ID Tray accessory.
If capture succeeds, the captured image is returned as the image parameter of the completion callback, and the error parameter is nil. If capture fails, the image parameter is nil, and the error parameter is non-nil.
id1CardDetectionMode and AilaID1CardDetectedNotification may be used to automatically detect the presence of a card.
Error Domains
AilaID1ImageCaptureTimeoutError
This error occurs when a clean image could not be captured within 10 seconds, due to any of the following causes:
- Unable to achieve correct camera focus
- Unable to achieve correct exposure (Note: the Aila Interactive Kiosk supplies enough light to operate without ambient lighting, but if the hardware is unpowered or lighting levels have been overridden, low exposure may occur)
Usage
- Objective-C
- Swift
// Enable card detection
AilaConfiguration *config = [[AilaConfiguration alloc] init];
config.id1CardDetectionMode = AilaID1CardDetectionModeOn;
Aila_SetConfiguration(config);
// Listen for card detected
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleCardDetected:)
name:AilaID1CardDetectedNotification
object:nil];
// Capture when card is detected
- (void)handleCardDetected:(NSNotification *)notification {
Aila_ID1CaptureImage(^(UIImage *image, NSError *error) {
if (error) {
NSLog(@"Capture failed: %@", error.domain);
} else {
NSLog(@"Captured image: %@", image);
// Process the captured image
}
});
}
// Enable card detection
let config = AilaConfiguration()
config.id1CardDetectionMode = .on
Aila_SetConfiguration(config)
// Listen for card detected
NotificationCenter.default.addObserver(
self,
selector: #selector(handleCardDetected),
name: NSNotification.Name(AilaID1CardDetectedNotification),
object: nil
)
// Capture when card is detected
@objc func handleCardDetected(_ notification: Notification) {
Aila_ID1CaptureImage { image, error in
if let error = error {
print("Capture failed: \(error.localizedDescription)")
} else if let image = image {
print("Captured image: \(image)")
// Process the captured image
}
}
}
See Also
- AilaID1CardDetectionMode - Card detection configuration
- AilaID1CardDetectedNotification - Card detection notification
- AilaImageCaptureDebugMode - Debug mode for failed captures