Skip to content

Hologram

On the Turkish ID card and driving licence, the hologram is checked with a short video in which the user tilts the document slightly. HologramController shows the camera, guides the user and records the video.

import UIKit
import RKYC_iOS
import id_card_detection_ios_cnn
final class HologramViewController: UIViewController {
@IBOutlet weak var containerView: UIView!
private let hologramController = HologramController()
override func viewDidLoad() {
super.viewDidLoad()
HologramController.USE_CARD_DETECTION = true
HologramController.HOLOGRAM_CONTROL_ENABLED = true
HologramController.CONTROL_FACE_CAPTURE = true
HologramController.STOP_VIDEO_WHILE_RECORDING = true
hologramController.cardType = .NEW_TC_ID // .DRIVER_LICENSE for the driving licence
hologramController.setDelegate(self)
hologramController.setFlashDelegate(self) // optional
containerView.addSubview(hologramController.view)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
hologramController.startCapture()
}
}
extension HologramViewController: HologramDelegate {
func onVideoCaptured(videoURL: URL, rotate: Int) {
hologramController.stopCapture()
// Send the video (below), then delete the file
}
func onVideoStarted() { }
func onVideoCanceled() { /* the document left the frame; ask the user to try again */ }
func onFaceDetectionSuccess() { }
func onFaceDetectionIdle() { }
}
import ProveIDApiClient
guard let video = try? Data(contentsOf: videoURL) else { return }
let body = HologramDetectionInputModel(video: video.base64EncodedString(),
rotate: rotate,
cardType: "NEW-ID",
transactionId: transactionId)
IDServiceAPI.detectHologram(body: body) { result in
switch result {
case .success(let response):
let score = response.controlResults.first { $0.entryType == "HOLOGRAM" }?.entryScore
showHologramResult(score)
case .failure(let error):
showError(error)
}
}
try? FileManager.default.removeItem(at: videoURL) // don't leave the video on the device
Document HologramCardType cardType
Turkish ID card .NEW_TC_ID NEW-ID
Driving licence .DRIVER_LICENSE NEW-DRIVER
Other ID cards .INTERNATIONAL_ID INTERNATIONAL

HologramFlashDelegate reports what the user should do while the video is being recorded:

Method When
onFlashNotOnCard() The flash reflection is not on the document
onFlashCircleCompleted(circleIndex:) One of the target shapes was completed
onFlashPositionUpdate(isFlashOnTarget:) The reflection moved on or off the target
onFlashNeedsMoreFrames() More movement is needed
onCardNotInHint() The document is outside the frame
onTooMuchGlare() Too much glare on the document
onWrongCardType(detectedCardType:isBackside:) A different document, or the other side, is shown
Setting Description
HologramController.USE_CARD_DETECTION Detects the document in the frame before recording
HologramController.HOLOGRAM_CONTROL_ENABLED Checks the hologram on the device while recording
HologramController.CONTROL_FACE_CAPTURE Requires the document photo to be visible
HologramController.STOP_VIDEO_WHILE_RECORDING Cancels the recording if the document leaves the frame
HologramController.HINT_DISPLAY_RATIO Size of the frame hint (e.g. 1.5)
HologramController.MARGIN_RATIO Margin around the hint (e.g. 0.2)
HologramController.OUTSIDE_OF_HINT_COLOR Colour outside the hint
HologramController.IS_TRADEMARK_LOGO_ON Shows the Techsign logo