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.

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.
Drop files here or click to browse
JPG · PNG · WebP · up to 500 files · max 4.5 MB each
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
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.
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.
Pakistan CNIC OCR Python SDK
Python Tutorial: Automate KYC in Pakistan. Extract data from CNIC using StructOCR Python SDK. Supports native text.
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.
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 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.
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.
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.
Nigeria NIN Slip OCR Python SDK
Python Tutorial: Automate KYC in Nigeria. Extract data from NIN Slip using StructOCR Python SDK. Supports native text.
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.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
Add National ID OCR to Your Bolt.new App in 5 Minutes
Step-by-step guide to integrating the StructOCR National ID scanner API into a Bolt.new app. Build KYC and identity verification flows right in your browser.
Add National ID OCR using Cursor in 5 Minutes
Step-by-step guide to integrating the StructOCR National ID scanner API using the Cursor AI code editor. Build KYC and identity verification flows rapidly.
Add National ID OCR to Your Lovable.dev App in 5 Minutes
Step-by-step guide to integrating the StructOCR National ID scanner API into a Lovable.dev app. Build KYC and identity verification flows with zero backend.
Add National ID OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR National ID scanner API into a Replit application. Build KYC and identity verification flows using Replit Agent and Secrets.
Add National ID OCR to Your v0 App in 5 Minutes
Step-by-step guide to integrating the StructOCR National ID scanner API into a v0 by Vercel app. Build KYC and identity verification flows with zero backend.
Add Passport OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR Passport scanner API into a Replit application. Build travel, hospitality, and global KYC flows using Replit Agent and Secrets.
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.