Enable OCR VIN support
What is OCR VIN Support #
OCR support in the barKoder SDK is currently intended primarily for VIN code recognition. Since the SDK is focused on barcode scanning, our OCR implementation has been optimized specifically for VIN use cases.
To enable VIN OCR in the barKoder SDK:
Enable OCR in the decoder configuration #
guard let decoderConfig = barkoderView.config?.decoderConfig else { return }
// Enable OCR functionality
decoderConfig.setcustomOption("enable_ocr_functionality", value: 1)
// Enable OCRText symbology
decoderConfig.ocrText.enabled = true
// Optional: enable other barcode types alongside OCR
decoderConfig.code39.enabled = true
// enableVINRestrictions (only decode VIN-compliant barcodes / strings)
decoderConfig.enableVINRestrictions = true
Available symbologies #
As mentioned in the VIN section of our site, VIN scanning works with the following symbologies:
private func setVin() {
// In order to perform scanning, config property need to be set before
// If license key is not valid you will receive results with asterisks inside
barkoderView.config = BarkoderConfig(licenseKey: "LICENSE_KEY") { licenseResult in
print("Licensing SDK: \(licenseResult)")
}
// Enabling symbologies
barkoderView.config?.decoderConfig?.qr.enabled = true
barkoderView.config?.decoderConfig?.datamatrix.enabled = true
barkoderView.config?.decoderConfig?.code128.enabled = true
barkoderView.config?.decoderConfig?.code39.enabled = true
barkoderView.config?.decoderConfig?.ocrText.enabled = true
// Setting ROI
barkoderView.config?.decoderConfig?.enableVINRestrictions = true
let vinRoiRect = CGRect(x: 0, y: 35, width: 100, height: 30)
try? self.barkoderView.config?.setRegionOfInterest(vinRoiRect)
barkoderView.config?.regionOfInterestVisible = true
// For best result decoding speed should be slow, and barkoder resolution should be Full HD
barkoderView.config?.decoderConfig?.decodingSpeed = DecodingSpeed.init(2) // Slow
barkoderView.config?.barkoderResolution = .FHD
}
The SDK will first attempt to extract the VIN from supported barcode formats such as Code 39, Code 128, Data Matrix, or QR codes. If barcode decoding is unsuccessful due to poor lighting or other conditions, the SDK will fall back to OCR and decode the visible text portion of the VIN, which is typically readable to the naked eye. This approach ensures the most reliable and optimal results.