Ghana Ghana Card OCR Python SDK

Instantly extract visual data, Personal ID Number, and validate cryptographic MRZ checksums from Ghanaian IDs using our native Python library.

AI extracting data, Personal ID Number, and TD1 MRZ from a Ghana Card
StructOCR engine analyzing a Ghanaian document and cross-validating the MRZ in real-time.

Parsing Ghana Card Challenges

The Ghana Card presents unique OCR challenges. First, layout variations across different card versions can confuse standard OCR engines. Second, the print quality, complex background patterns, and potential for glare can lead to inaccurate text recognition. Finally, ensuring the document's authenticity requires reliably locating and strictly validating the Machine-Readable Zone (MRZ) on the back of the ECOWAS-standard card.

Why StructOCR for Ghana

StructOCR's model is specifically trained on a large dataset of Ghanaian National ID cards, offering robust national id ocr capabilities. This specialized training enables superior accuracy in extracting key information, including the critical Personal ID Number (PIN). Our Python SDK simplifies integration by automatically handling image preprocessing and actively parsing the embedded MRZ to facilitate secure kyc automation processes.

Common Use Cases in Ghana

  • Digital Onboarding: Verify users for Fintech apps in Ghana by pre-filling the Personal ID Number and validating the MRZ in < 2 seconds.
  • Telecom Registration: Automate SIM card registration with robust extraction of Ghanaian addresses and identifiers.
  • Hotel Check-in: Speed up guest registration workflows with automated MRZ scanning.

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`. The SDK automatically maps Ghana-specific fields and extracts the raw TD1 MRZ lines.

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

from structocr import StructOCR

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

def scan_ghana_id():
    # Note: Supports JPG, PNG, WebP (Max 4.5MB)
    # Target: Ghana Card
    image_path = "ghana_national_id.jpg"

    try:
        print(f"Scanning {image_path}...")
        
        # The SDK handles file upload and API communication
        result = client.scan_national_id(image_path)

        if result.get('success'):
            data = result['data']
            print("✅ Ghana 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"Document No: {data.get('document_number')}")
            
            # Critical Field: Personal ID Number
            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')}")
            
            # Extract TD1 MRZ Data
            additional = data.get('additional_fields', {})
            if additional.get('mrz_line_1'):
                print("\n🔍 MRZ Data Extracted & Validated:")
                print(f"Line 1: {additional.get('mrz_line_1')}")
                print(f"Line 2: {additional.get('mrz_line_2')}")
                print(f"Line 3: {additional.get('mrz_line_3')}")
        else:
            print(f"❌ Extraction Failed: {result.get('error')}")

    except Exception as e:
        print(f"An error occurred: {e}")

if __name__ == "__main__":
    scan_ghana_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 + MRZ Block)

Key Features

  • Personal ID Number Extraction: Automatically locates and accurately formats the critical GHA-formatted identity number.
  • Hybrid VIZ + MRZ AI: Cross-validates unstructured visual data against cryptographic TD1 MRZ checksums for zero hallucination.
  • Blur Detection: Automatically rejects blurry images.
  • Smart Crop: Removes background noise and deskews automatically, ideal for mobile submissions.

JSON Response Example

The SDK returns a Python dictionary matching this JSON structure, including the parsed visual data (VIZ), the Personal ID Number, and the raw Machine-Readable Zone (MRZ).

{
  "success": true,
  "data": {
    "type": "national_id",
    "country_code": "GHA",
    "nationality": "GHANA",
    "document_number": "GHA-712345678-9",
    "card_series": "",
    "personal_number": "GHA-712345678-9",
    "surname": "MENSAH",
    "given_names": "KWAME",
    "sex": "M",
    "date_of_birth": "1990-05-15",
    "place_of_birth": "ACCRA",
    "address": "House No. B24, Osu, Accra",
    "date_of_issue": "2020-01-01",
    "date_of_expiry": "2030-01-01",
    "issuing_authority": "National Identification Authority",
    "additional_fields": {
      "tramite_number": null,
      "mrz_line_1": "I<GHAGHA<712345678<9<<<<<<<<<<",
      "mrz_line_2": "9005156M3001018GHA<<<<<<<<<<<4",
      "mrz_line_3": "MENSAH<<KWAME<<<<<<<<<<<<<<<<<"
    }
  }
}

Frequently Asked Questions

Does the SDK validate the MRZ on the back of the Ghana Card?

Yes. Our engine extracts the TD1 format MRZ lines and runs the ICAO 9303 checksum verification (modulus 10 with 7-3-1 weighting) to ensure data integrity.

Can it extract the Personal ID Number?

Absolutely. The models natively target the unique alphanumeric Personal ID format (e.g., GHA-123456789-0), mapping it directly to the `personal_number` field and verifying it against the embedded MRZ.

Does the Python SDK handle image uploads?

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

You May Also Like

Related tutorials, platform guides, and comparisons

Country Tutorial

Ghana Passport OCR with Python SDK

Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Ghana passports with a server-side integration.

Python · Passport
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

Pakistan CNIC OCR Python SDK

Python Tutorial: Automate KYC in Pakistan. Extract data from CNIC using StructOCR Python SDK. Supports native text.

Python · cnic
Country Tutorial

Germany Passport OCR with Python SDK

Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Germany passports with a server-side integration.

Python · Passport
Country Tutorial

Bangladesh Passport OCR with Python SDK

Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Bangladesh passports with a server-side integration.

Python · Passport
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

Uzbekistan ID Karta OCR Python SDK

Python Tutorial: Automate KYC in Uzbekistan. Extract data from ID Karta using StructOCR Python SDK. Supports native text and MRZ parsing.

Python · id karta
Country Tutorial

Morocco CNIE OCR Python SDK

Python Tutorial: Automate KYC in Morocco. Extract data from CNIE using StructOCR Python SDK. Supports native text and MRZ extraction.

Python · cnie
Country Tutorial

Nigeria NIN Slip OCR Python SDK

Python Tutorial: Automate KYC in Nigeria. Extract data from NIN Slip using StructOCR Python SDK. Supports native text.

Python · nin slip & e-id
Country Tutorial

Netherlands Identiteitskaart OCR Python SDK

Python Tutorial: Automate KYC in Netherlands. Extract data from Identiteitskaart using StructOCR Python SDK. Supports native text and MRZ extraction.

Python · identiteitskaart

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