The Best Python Library for Shipping Container OCR

Stop using regex. Extract structured data from Shipping Containers with 99% accuracy using Python.

Shipping Container OCR extraction process diagram
StructOCR transforms raw Shipping Container images into validated JSON.

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.

Live Demo: Container OCR

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 200 Container 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.

PYTHON EXAMPLE
from structocr import StructOCR
from structocr.exceptions import APIError, InvalidAPIKeyError

# 💰 Save 30%+ vs competitors. Get 200 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: < 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

  • 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.

You May Also Like

Related tutorials, platform guides, and comparisons

Tutorial

Java Shipping Container OCR API

Upload an image for a free test! Tutorial: Learn how to use the StructOCR Java Client to extract data from Shipping Containers. Extract ISO 6346 container numbers with 99% accuracy.

Java · Container
Tutorial

PHP Shipping Container OCR API

Tutorial: Learn how to use the StructOCR PHP Client via cURL for shipping container OCR. Upload an image for a free test! Extract ISO 6346 container numbers with 99% accuracy. Includes code samples and JSON schemas.

PHP · Container
Tutorial

Node.js Shipping Container OCR API

Tutorial: How to use the StructOCR Node.js SDK to extract data from Shipping Containers. Upload an image for a free test! Includes code samples and JSON schema.

Node.js · Container
Tutorial

Go Shipping Container OCR API

Upload an image for a free test! Tutorial: Learn how to use the StructOCR Go Client to extract data from Shipping Containers. Extract ISO 6346 container numbers with 99% accuracy. Includes code samples and JSON schema.

Go · Container
Tutorial

C# Shipping Container OCR API

Upload an image for a free test! Tutorial: Learn how to use the StructOCR C# Client to extract data from Shipping Containers. Extract ISO 6346 container numbers with 99% accuracy. Includes code samples and JSON schemas.

C# · Container
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

Serbia Lična karta OCR Python SDK

Python Tutorial: Automate KYC in Serbia. Extract data from Lična karta using StructOCR Python SDK. Supports native text and MRZ extraction.

Python · lična karta
Country Tutorial

Senegal Carte d'Identité CEDEAO OCR Python SDK

Python Tutorial: Automate KYC in Senegal. Extract data from Carte d'Identité CEDEAO using StructOCR Python SDK. Supports native text and MRZ extraction.

Python · carte d'identité cedeao
Country Tutorial

Romania Carte de Identitate OCR Python SDK

Python Tutorial: Automate KYC in Romania. Extract data from Carte de Identitate using StructOCR Python SDK. Supports native text, front/back sides, and MRZ extraction.

Python · carte de identitate
Country Tutorial

Portugal Cartão de Cidadão OCR Python SDK

Python Tutorial: Automate KYC in Portugal. Extract data from Cartão de Cidadão using StructOCR Python SDK. Supports native text and MRZ extraction.

Python · cartão de cidadão

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