QRCode Scanner using Apple in build Vision framework.

Last update: Jun 7, 2022

🔲 iOS13 DKQRReader Example

A quick example showing how to use the Vision system-framework in iOS 13 and Swift 5.

Prerequisites

  • Xcode 13 and later

Getting Started

First, import the Vision framework.

import Vision

Next, create a barcode-request that will call the completion-handler asynchronously when it detects a code:

// Create a barcode detection-request
let barcodeRequest = VNDetectBarcodesRequest(completionHandler: { request, error in

    guard let results = request.results else { return }

    // Loop through the found results
    for result in results {
        
        // Cast the result to a barcode-observation
        if let barcode = result as? VNBarcodeObservation {
            
            // Print barcode-values
            print("Symbology: \(barcode.symbology.rawValue)")
            
            if let desc = barcode.barcodeDescriptor as? CIQRCodeDescriptor {                
                print("Error-Correction-Level: \(desc.errorCorrectionLevel)")
                print("Symbol-Version: \(desc.symbolVersion)")
            }
        }
    }
})

Finally, call the image-request-handler with the previously create barcode-request:

// Create an image handler and use the CGImage your UIImage instance.
guard let image = myImage.cgImage else { return }
let handler = VNImageRequestHandler(cgImage: image, options: [:])

// Perform the barcode-request. This will call the completion-handler of the barcode-request.
guard let _ = try? handler.perform([barcodeRequest]) else {
    return print("Could not perform barcode-request!")
}

That's it! Run the app on the simulator / device and detect QR-codes.

Author

Dineshkumar Kandasamy

GitHub

https://github.com/DineshkumarKandasamy/DKQRReader
You might also like...

Text-cli - Command line tool for extracting text from images using Apple's Vision framework

Text-cli - Command line tool for extracting text from images using Apple's Vision framework

text-cli Command line tool for extracting text from images using Apple's Vision

Apr 23, 2022

Simple command-line utility for performing OCR using Apple's Vision framework

ocrit Runs Vision's OCR on input images and outputs corresponding txt files for each image, or writes the recognized results to standard output. USAGE

Jun 27, 2022

Simple QRCode reader in Swift

Simple QRCode reader in Swift

QRCodeReader.swift is a simple code reader (initially only QRCode) for iOS in Swift. It is based on the AVFoundation framework from Apple in order to

Jun 13, 2022

Simple QRCode reader in Swift

Simple QRCode reader in Swift

QRCodeReader.swift is a simple code reader (initially only QRCode) for iOS in Swift. It is based on the AVFoundation framework from Apple in order to

Jun 13, 2022

A QRCode generator written in Swift.

A QRCode generator written in Swift.

QRCode 🔳 A QRCode generator written in Swift. Overview Create a new QRCode representing a URL, a string or arbitrary data. The following examples all

Jun 9, 2022

A Demo using Vision Framework building on Core ML Framework

A Demo using Vision Framework building on Core ML Framework

Core-ML-Sample A Demo using Core ML, Vision Framework and Swift 4. This demo is based on Inception V3 network. You must run it with Xcode 9 and iOS 11

Mar 30, 2022

Utilizing Apple's Vision Framework to center faces in CGImage.

Utilizing Apple's Vision Framework to center faces in CGImage.

FaceCrop CGImage extension that utilizes Apple's Vision Framework to detect and center faces. Usage cgImage.faceCrop { [weak self] result in switc

Jun 21, 2022

Text Classifier App for iOS, powered by Apple Vision & CreateML framework

Text Classifier App for iOS, powered by Apple Vision & CreateML framework

Text Classifier App for iOS, powered by Apple Vision & CreateML framework

Nov 17, 2021

A simple macOS app to read code from images, written purely in Swift using Vision Framework.

A simple macOS app to read code from images, written purely in Swift using Vision Framework.

CodeReader A simple macOS app to read code from images, written purely in Swift using Vision Framework. Usage Drag an image Click the convert button R

Apr 11, 2022

Autocrop - A face-aware crop utility using OSX's Vision framework

autocrop A high-performance face-aware crop utility using OSX's Vision framework

Jan 19, 2022

Screen translator for macOS with Apple Vision API and IBM Watson, Google Cloud Translator

Screen translator for macOS with Apple Vision API and IBM Watson, Google Cloud Translator

Swifty-OCR-Translator Screen translator for macOS with Apple Vision API and IBM Watson, Google Cloud Translator Usage Select Translator Fill in the AP

Apr 22, 2022

:mag_right: A simple and beautiful barcode scanner.

:mag_right: A simple and beautiful barcode scanner.

Description BarcodeScanner is a simple and beautiful wrapper around the camera with barcode capturing functionality and a great user experience. Barco

Jun 21, 2022

CarBode : Free & Opensource barcode scanner & generator for SwiftUI

CarBode : Free & Opensource barcode scanner & generator for SwiftUI

CarBode Free and Opensource Barcode scanner & Barcode generator for swiftUI Why you must use CarBode CarBode have both Barcode Scanner and Barcode Gen

Jun 5, 2022

:mag_right: A simple and beautiful barcode scanner.

:mag_right: A simple and beautiful barcode scanner.

Description BarcodeScanner is a simple and beautiful wrapper around the camera with barcode capturing functionality and a great user experience. Barco

Jun 21, 2022

QR Blank - QR Code URL scanner

 QR Blank - QR Code URL scanner

QR Blank - QR Code URL scanner No Ads, Clean, Simple open source QR Code URL scanner Check URL by Google Safe Browsing before open. Google Safe Browsi

Feb 7, 2022

A simple and beautiful barcode scanner.

A simple and beautiful barcode scanner.

Description BarcodeScanner is a simple and beautiful wrapper around the camera with barcode capturing functionality and a great user experience. Barco

Jun 15, 2022

An iOS LAN Network Scanner library

An iOS LAN  Network Scanner library

MMLanScan MMLanScan is an open source project for iOS that helps you scan your network and shows the available devices and their MAC Address, hostname

Jun 7, 2022

QR Barcode Scanner For Swift

QRBarcodeScanner Example To run the example project, clone the repo, and run pod

Dec 22, 2021

A credit card scanner for iOS written in Swift

A credit card scanner for iOS written in Swift

DGCardScanner A credit card scanner Requirements iOS 13.0+ Swift 5.5+ Xcode 10.0+ Installation SPM File Add Packages https://github.com/donggyushi

Mar 28, 2022
Simple QRCode reader in Swift
Simple QRCode reader in Swift

QRCodeReader.swift is a simple code reader (initially only QRCode) for iOS in Swift. It is based on the AVFoundation framework from Apple in order to

Jun 13, 2022
:mag_right: A simple and beautiful barcode scanner.
:mag_right: A simple and beautiful barcode scanner.

Description BarcodeScanner is a simple and beautiful wrapper around the camera with barcode capturing functionality and a great user experience. Barco

Jun 21, 2022
QR Blank - QR Code URL scanner
 QR Blank - QR Code URL scanner

QR Blank - QR Code URL scanner No Ads, Clean, Simple open source QR Code URL scanner Check URL by Google Safe Browsing before open. Google Safe Browsi

Feb 7, 2022
BarcodeScannerSwift - Barcode Scanner Built With Swift

BarcodeScannerSwift This repository was built for a supermarket. Employees can k

Jun 21, 2022
A Simple iOS QR code scanner that allows users to enable their camera and local Photo Library accesses to scan the contents of the input QR codes.

iOS QR Code Scanner A Simple iOS QR code scanner using Swift UI. Jump to: ContentView.swift screenshot 1.1.5 NOTE: be aware of the new horizontal line

Jun 19, 2022
A QR Code Scanning Framework For IOS

QRReader A QR Code Scanning Framework For IOS Requirements: IOS 11+ Xcode: 12+ Installation: steps to install this framework in your xcode project Pod

Jan 9, 2022
GraphQL-GitHub-Reader - Simple sample project that demonstrates how to connect with GitHub's API using GraphQL + Apollo
GraphQL-GitHub-Reader - Simple sample project that demonstrates how to connect with GitHub's API using GraphQL + Apollo

GHPViewer A beatiful way to see your GitHub Profile Installation The project is splitted in two folders: GHPViewer: Contains the iOS Application relat

Jan 2, 2022
🏁 make QRcode and QRcode Reader Tutorial
🏁 make QRcode and QRcode Reader Tutorial

QRCodeReaderTutorial-iOS ?? make QRcode and QRcode Reader Tutorial QR코드와 리더기를 만드는 오픈 라이브러리가 있지만 자체 라이브러리를 활용해서 만들어보기로 했다. 목차 QR코드 만들기 QR코드 Reader 만들기

Dec 9, 2021
SharkCardScan is a Credit/Debit Card scanner built using Apple's Vision Framework.
SharkCardScan is a Credit/Debit Card scanner built using Apple's Vision Framework.

iOS Credit/Debit card scanner, built using Apple's Vision Framework.

Jun 3, 2022
Vision Camera 📸 The Camera library that sees the vision.
Vision Camera 📸 The Camera library that sees the vision.

Vision Camera ?? The Camera library that sees the vision. npm i react-native-vision-camera npx pod-install Documentation Guides API Ex

Jun 24, 2022