1. Products
  2.   OCR
  3.   Swift
  4.   Evil
 
  

Free Swift OCR API to Read ID & Bank Cards Numbers

Open Source Top Swift Optical Character Recognition (OCR) Library for Recognizing & Reading Numbers from ID Cards, Bank Cards, House Numbers & Documents via Free Swift API.

What is Evil?

For software developers building on Apple platforms, integrating Optical Character Recognition (OCR) into iOS and macOS applications is streamlined with the open-source Evil library. This Swift-based solution harnesses the on-device power of Apple's Vision framework to provide a high-level API for extracting text from images with remarkable efficiency. Designed as a developer-first tool, Evil simplifies the complex process of adding robust OCR capabilities, enabling you to quickly recognize text from sources like bank cards, ID cards, or door numbers directly within your Swift projects.

The Evil library excels at extracting structured data by combining Swift-native performance with exceptional flexibility through Core ML model (.mlmodel) integration. This model-based architecture allows developers to deploy pre-trained models for immediate use or train and implement custom models tailored to specific recognition tasks. By offering simple APIs alongside flexible model deployment, Evil delivers a streamlined, high-performance OCR experience that is perfectly suited for creating sophisticated, on-device text extraction features in your mobile and desktop applications for iOS and macOS.

Previous Next

Getting Started with Evil

The recommend way to install Evil is using CocoaPods. Please use the following command for a smooth installation.

Install Evil Library via CocoaPods

 pod 'evil'

Install Evil Library via GitHub

 git clone https://github.com/getomni-ai/zerox.git 

You can also install it manually; download the latest release files directly from GitHub repository.

Recognize Numbers in Images via Swift API

Built entirely in Swift, Evil supports both iOS (11.0+) and macOS (10.13+), making it versatile for native Apple ecosystem development. The open source Evil library offers complete support for number recognition from structured data inside Swift applications. The primary goal of the Evil library is to make text recognition from images, such as bank cards, ID cards, and even door numbers, as straightforward as possible for software developers. Once you have initialized the Evil library, recognizing text from an image is as simple as calling the recognize method, the following example demonstrates how to do it.

How to Recognize Numbers from an Image via Swift API?

let image: Recognizable = // Your image (e.g., a UIImage or CGImage)
let result = evil?.recognize(image)
print(result)

// This returns the OCR result—typically the detected number or text as a string 

// Run OCR on Input Image

if let result = evil?.recognize(myImage) {
  print("Detected number: \(result)")
}

Advanced Memory Manipulation

The open source Swift Optical character recognition library Evil allows software developers to directly access and manipulate memory inside Swift applications. Thus making it useful for debugging, game hacking, or security testing. Here is useful example that demonstrates reading and writing to a specific memory location using Swift commands.

How to Read and Write to a Specific Memory Location via Swift API?

#include 

int main() {
    uintptr_t address = 0x00400000; // Example memory address
    uint8_t value = evil_read_memory(address); // Read a byte
    evil_write_memory(address, 0x90); // Write a NOP (0x90) instruction
    return 0;
}

Flexible Model Loading via URL

The open source Evil library offers multiple ways to load your Core ML models. You can bundle them directly with your application or, to reduce your app's initial download size, you can configure the library to download the models from a remote server at runtime. To keep your app bundle small, you can host your .mlmodel file on a server and have the Evil library download it at runtime.

How to Access Model from a Remote URL via Swift API?

let downloadURL = URL(string: "https://your-server.com/ChineseIDCard.mlmodel")!
let chineseIDCard = Recognizer.custom(name: "ChineseIDCard", model: downloadURL, needComplie: true, processor: Recognizer.cropChineseIDCardNumberArea)
let evil = try? Evil(recognizer: chineseIDCard)
 English