Uganda National ID Card OCR Python SDK

Instantly extract data and MRZ from Ugandan IDs using our native Python library.

AI extracting data from a Uganda ID card
StructOCR engine analyzing a Ugandan document and MRZ lines in real-time.

Parsing National ID Card Challenges

Uganda National ID Cards often present OCR challenges due to variations in print quality, especially on older cards. The layout can also differ slightly depending on the issuing branch, requiring a robust model to handle these inconsistencies. Additionally, while the primary language is English, some localized terms or abbreviations can appear.

Why StructOCR for Uganda

Our OCR model is specifically trained on a large dataset of Ugandan National ID Cards, enabling accurate id card parsing despite common challenges. It also fully supports parsing the Machine Readable Zone (MRZ) on the reverse side for strict identity verification. Our Python SDK simplifies integration, allowing seamless incorporation of our OCR capabilities into existing applications with minimal code. It handles image preprocessing, API calls, and data parsing, facilitating kyc automation and saving valuable development time.

Common Use Cases in Uganda

  • Digital Onboarding: Verify users for Fintech apps in Uganda.
  • Telecom Registration: Automate SIM card registration with National ID Card.
  • Hotel Check-in: Speed up guest registration workflows.

Live Demo: ID card scanner

No registration required. Upload a file to test the extraction.

1
Upload
2
Results

Drop files here or click to browse

JPG · PNG · WebP  ·  up to 500 files · max 4.5 MB each

No files selected
Need more testing? Create a free account to get 200 free credits (equals 100 National ID scans).

Python SDK Integration

Install the SDK via pip: `pip install structocr`. Then use the following code.

Prerequisite: Python 3.6+ and `structocr` library installed.

from structocr import StructOCR

# 🔑 Need a key for Uganda? Get 200 free credits instantly:
# 👉 https://structocr.com/register
# Initialize with your API Key
client = StructOCR("YOUR_API_KEY_HERE")

def scan_uganda_id():
    # Note: Supports JPG, PNG, WebP (Max 4.5MB)
    # Target: National ID Card
    image_path = "uganda_national_id.jpg"

    try:
        print(f"Scanning {image_path}...")
        
        # The SDK handles file upload and API communication
        # It automatically detects that this is a Ugandan document
        result = client.scan_national_id(image_path)

        # Check success flag (SDK returns a dict matching the JSON response)
        if result.get('success'):
            data = result['data']
            print("✅ Uganda Extraction Successful!")
            
            # Basic Identity
            print(f"Region:      {data.get('country_code')} (Series: {data.get('card_series')})")
            print(f"Name:        {data.get('given_names')} {data.get('surname')}")
            print(f"ID Number:   {data.get('document_number')}")
            
            # Critical Field: Personal Identity Number (CNP/CPF/NIN)
            print(f"Personal #:  {data.get('personal_number')}")
            
            # Demographics
            print(f"DOB:         {data.get('date_of_birth')} ({data.get('sex')})")
            print(f"Address:     {data.get('address')}")

            # Machine Readable Zone (MRZ)
            additional = data.get('additional_fields', {})
            if additional.get('mrz_line_1'):
                print("\n--- MRZ Data ---")
                print(additional.get('mrz_line_1'))
                print(additional.get('mrz_line_2'))
                if additional.get('mrz_line_3'):
                    print(additional.get('mrz_line_3'))
        else:
            print(f"❌ Extraction Failed: {result.get('error')}")

    except Exception as e:
        # Handle SDK or Network errors
        print(f"An error occurred: {e}")

if __name__ == "__main__":
    scan_uganda_id()

Technical Specs

  • Latency: < 4s (Average)
  • Uptime: 99.9% SLA
  • Security: AES-256 Encryption & SOC2 Compliant
  • Input: JPG, PNG, WebP (Max 4.5MB)
  • Output: JSON (Structured Data)

Key Features

  • Native Script Support: Reads English and local characters.
  • MRZ Parsing: Accurately extracts and validates the Machine Readable Zone lines for cross-checking.
  • Blur Detection: Automatically rejects blurry images.
  • Fraud Check: Validates National ID Card number format.
  • Smart Crop: Removes background noise automatically.

JSON Response Example

The SDK returns a Python dictionary matching this JSON structure.

{
  "success": true,
  "data": {
    "type": "national_id",
    "country_code": "UGA",
    "nationality": "UGANDAN",
    "document_number": "012345678",
    "card_series": "",
    "personal_number": "CM90010101234A",
    "surname": "MUKASA",
    "given_names": "DAVID",
    "sex": "M",
    "date_of_birth": "1990-05-15",
    "place_of_birth": "KAMPALA",
    "address": "KAMPALA CENTRAL, KAMPALA",
    "date_of_issue": "2020-01-01",
    "date_of_expiry": "2030-01-01",
    "issuing_authority": "NIRA",
    "additional_fields": {
      "phone_number": null,
      "tramite_number": null,
      "ejemplar": null,
      "mrz_line_1": "IDUGA0123456784<<<<<<<<<<<<<<<",
      "mrz_line_2": "9005156M3001014UGA<<<<<<<<<<<4",
      "mrz_line_3": "MUKASA<<DAVID<<<<<<<<<<<<<<<<<"
    }
  }
}

Frequently Asked Questions

Does the Python SDK handle image uploads?

Yes, the SDK automatically handles base64 encoding and file uploads.

Is data stored?

No. Images are processed in-memory and deleted immediately.

How to handle errors?

The SDK result dictionary contains a 'success' boolean and an 'error' message if failed.

You May Also Like

Related tutorials, platform guides, and comparisons

Tutorial

Python National ID OCR API

High-accuracy National ID OCR for Python. Upload an image for a free test! Get structured JSON output via our dedicated Python SDK. Automate KYC and data entry with 99%+ accuracy.

Python · National ID
Country Tutorial

Tunisia CIN (Carte d'Identité Nationale) OCR Python SDK

Python Tutorial: Automate KYC in Tunisia. Extract data from CIN (Carte d'Identité Nationale) using StructOCR Python SDK. Supports native text.

Python · National ID
Country Tutorial

Saudi Arabia National ID & Iqama OCR Python SDK

Python Tutorial: Automate KYC in Saudi Arabia. Extract data from National IDs and Iqamas using the StructOCR Python SDK. Supports bilingual (Arabic/English) text, 10-digit ID numbers, and 3-line MRZ extraction.

Python · National ID
Country Tutorial

Bangladesh Smart NID OCR Python SDK

Python Tutorial: Automate KYC in Bangladesh. Extract complex Bengali text and decode 2D barcodes from Smart NIDs using StructOCR Python SDK.

Python · National ID
Country Tutorial

Ukraine National ID OCR Python SDK

Python Tutorial: Automate KYC in Ukraine. Extract data from National ID using StructOCR Python SDK. Supports native text and MRZ extraction.

Python · National ID
Country Tutorial

Kenya National ID (Maisha Card) OCR Python SDK

Python Tutorial: Automate KYC in Kenya. Extract data, Maisha Namba (UPI), and validate TD1 MRZ from National ID (Maisha Card) using StructOCR Python SDK.

Python · National ID
Country Tutorial

Côte d'Ivoire CNI (Carte Nationale d'Identité) OCR Python SDK

Python Tutorial: Automate KYC in Côte d'Ivoire. Extract French text, NNI, and validate TD1 MRZ from the ONECI CNI using StructOCR Python SDK.

Python · National ID
Country Tutorial

Malaysia MyKad OCR with Node.js SDK

Extract identity number, names, dates and other visible fields from MyKad with the StructOCR Node.js SDK and Express.

Node.js · National ID
Country Tutorial

India Aadhaar OCR with Node.js SDK

Extract Aadhaar number, names, dates and other visible fields from Aadhaar card with the StructOCR Node.js SDK and Express.

Node.js · National ID
Country Tutorial

Indonesia KTP OCR with Node.js SDK

Extract NIK, names, dates and other visible fields from Kartu Tanda Penduduk (KTP) with the StructOCR Node.js SDK and Express.

Node.js · National ID

Technical Comparisons & Integrations

Explore platform integrations and competitive analysis

From tutorial to production in 5 minutes.

You've seen the code. Now get your API key, grab your 200 free credits, and see it work with your own images. No credit card required.

Instant Access Cancel Anytime 99.9% Uptime