The Best Python Library for Shipping Container OCR
Stop using regex. Extract structured data from Shipping Containers with 99% accuracy using Python.

The Problem with Shipping Container Parsing
Shipping containers often present challenges for traditional OCR methods. Factors like glare, holograms, skewed angles, varying fonts, and damage degrade the accuracy of regular expression or template-based systems. Vertical text, common in port environments, is especially difficult. These systems struggle to cope with real-world variations, leading to high error rates.
The StructOCR Solution
StructOCR utilizes advanced deep learning models specifically trained on shipping container data, ensuring ISO 6346 compliant extraction is achieved. Our AI automatically handles deskewing, perspective correction, smart cropping, and vertical text reading, providing accurate and reliable results for applications such as logistics and port automation every time.
Common Use Cases
- KYC/Onboarding: Automate user verification flow.
- Data Entry Automation: Eliminate manual typing errors.
- Fraud Detection: Identify inconsistent data fields.
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
from structocr.exceptions import APIError, InvalidAPIKeyError
# 💰 Save 30%+ vs competitors. Get 20 free credits instantly:
# 👉 https://structocr.com/register
# Initialize with your API Key
client = StructOCR("YOUR_API_KEY_HERE")
def scan_shipping_container():
# Note: Supports JPG, PNG, WebP (Max 4.5MB)
# Target: Shipping Container Number (ISO 6346)
image_path = "container_image.jpg"
try:
print(f"Scanning {image_path}...")
# The SDK handles file upload and API communication
result = client.scan_container(image_path)
if result and result.get('success'):
data = result['data']
print("✅ Container Extraction Successful!")
print(f"Container Number: {data.get('container_number')}")
print(f"Is Valid (Check Digit): {data.get('is_valid')}")
print(f"Confidence: {data.get('confidence')}")
parsed_data = data.get('parsed', {})
print(f"Owner Code: {parsed_data.get('owner_code')}")
print(f"Category: {parsed_data.get('category')}")
print(f"Serial Number: {parsed_data.get('serial_number')}")
print(f"Check Digit: {parsed_data.get('check_digit')}")
if data.get('is_valid'):
print("\nContainer number check digit is valid.")
else:
print("\nContainer number check digit is invalid. Please verify.")
else:
print(f"❌ Extraction Failed: {result.get('error')}")
except InvalidAPIKeyError as e:
print(f"Error: Invalid API Key. {e}")
except APIError as e:
print(f"Error communicating with the API: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
if __name__ == "__main__":
scan_shipping_container()Technical Specs
- •Latency: < 5s (Average)
- •Uptime: 98.5% SLA
- •Security: AES-256 Encryption & SOC2 Compliant
- •Input: JPG, PNG, WebP (Max 4.5MB)
- •Output: JSON (Structured Data)
Key Features
- •Smart Crop: Auto-detects document boundaries.
- •Field Validation: Cross-validates dates and checksums.
- •Specialized Models: Trained specifically on Shipping Containers.
Sample JSON Response
The API returns a clean JSON object with normalized fields.
{
"success": true,
"data": {
"container_number": "TTNU5194822",
"is_valid": true,
"confidence": "High",
"parsed": {
"owner_code": "TTN",
"category": "U",
"serial_number": "519482",
"check_digit": "2"
}
}
}Frequently Asked Questions
What file formats are supported?
JPG, PNG, and WebP images up to 4.5MB.
Is data stored?
No. Images are processed in-memory and deleted immediately.
How to handle errors?
Check the 'success' flag and 'error' message in the response.
More OCR Tutorials
Python Driver License OCR API
Stop struggling with manual driver's license data entry. Our Python OCR API delivers structured JSON in <5s average latency, secured by AES-256 and 98.5% uptime SLA.
Python HIN (Hull Identification Number) OCR API SDK
Tutorial: Extract Hull Identification Numbers (HIN) using the StructOCR Python SDK. Perfect for marine data pipelines, ETL workflows, and automated watercraft valuations.
Python Invoice Line Item OCR API
Struggling with invoice line item extraction? Our Python OCR API delivers structured JSON in under 5s, ensuring 98.5% uptime and SOC2 compliance. Secure your data.
Python National ID OCR API
High-accuracy National ID OCR for Python. Get structured JSON output via our dedicated Python SDK. Automate KYC and data entry with 99%+ accuracy.
Precise Data Extraction and Seamless
Integration with AI-powered OCR API.
Empower your solutions with automated data extraction by
integrating best-in class StructOCR via API seamlessly.
No credit card required • Full API access included