MareArts ANPR mobile app

12/30/2025

MareArts ANPR V14 - Easy 3-Method Integration (File, OpenCV, PIL)


πŸš€ MareArts ANPR V14 - Getting Started in 3 Easy Ways

Welcome to MareArts ANPR V14! Today I'll show you how to process license plates using three different methods: from files, OpenCV, or PIL. Plus, the new multi-region switching feature that saves memory.

πŸ“¦ Quick Setup

pip install marearts-anpr
ma-anpr config  # Enter your credentials

🎯 Basic Usage - Three Input Methods

from marearts_anpr import ma_anpr_detector_v14, ma_anpr_ocr_v14
from marearts_anpr import marearts_anpr_from_image_file, marearts_anpr_from_cv2, marearts_anpr_from_pil
import cv2
from PIL import Image

# Initialize detector and OCR (once)
detector = ma_anpr_detector_v14(
    "medium_640p_fp32",
    user_name, serial_key, signature,
    backend="cpu",
    conf_thres=0.25
)

ocr = ma_anpr_ocr_v14("medium_fp32", "eup", user_name, serial_key, signature)

# Method 1: From file (easiest!)
result = marearts_anpr_from_image_file(detector, ocr, "plate.jpg")
print(result)

# Method 2: From OpenCV
img = cv2.imread("plate.jpg")
result = marearts_anpr_from_cv2(detector, ocr, img)
print(result)

# Method 3: From PIL
pil_img = Image.open("plate.jpg")
result = marearts_anpr_from_pil(detector, ocr, pil_img)
print(result)

🌍 NEW: Dynamic Region Switching (Saves 180MB!)

Previously, you needed separate OCR instances for each region. Now use set_region():

# Initialize once with any region
ocr = ma_anpr_ocr_v14("medium_fp32", "eup", user_name, serial_key, signature)

# Switch regions instantly!
ocr.set_region('eup')   # European plates
result = marearts_anpr_from_image_file(detector, ocr, "eu-plate.jpg")

ocr.set_region('kr')    # Korean plates  
result = marearts_anpr_from_image_file(detector, ocr, "kr-plate.jpg")

ocr.set_region('na')    # North American plates
result = marearts_anpr_from_image_file(detector, ocr, "us-plate.jpg")

ocr.set_region('cn')    # Chinese plates
ocr.set_region('univ')  # Universal

Memory savings: Single instance vs multiple = ~180MB saved per additional region!

πŸ“Š Available Regions

  • kr - Korean plates (123κ°€4567)
  • eup - European plates (EU standards)
  • na - North American plates (USA, Canada, Mexico)
  • cn - Chinese plates (δΊ¬A·12345)
  • univ - Universal (all regions, slightly lower accuracy)

🎨 Batch Processing

# Detect plates from multiple images
img1 = cv2.imread("plate1.jpg")
img2 = cv2.imread("plate2.jpg")

detections1 = detector.detector(img1)
detections2 = detector.detector(img2)

# Collect plate crops
plates = []
for det in detections1:
    bbox = det['bbox']
    crop = img1[int(bbox[1]):int(bbox[3]), int(bbox[0]):int(bbox[2])]
    plates.append(Image.fromarray(cv2.cvtColor(crop, cv2.COLOR_BGR2RGB)))

for det in detections2:
    bbox = det['bbox']
    crop = img2[int(bbox[1]):int(bbox[3]), int(bbox[0]):int(bbox[2])]
    plates.append(Image.fromarray(cv2.cvtColor(crop, cv2.COLOR_BGR2RGB)))

# Process all plates at once!
results = ocr.predict(plates)  # Pass list of images

for i, (text, conf) in enumerate(results):
    print(f"Plate {i+1}: {text} ({conf}%)")

πŸ”§ Model Options

Detector models:

  • pico_640p_fp32 - Smallest, fastest
  • micro_640p_fp32
  • small_640p_fp32
  • medium_640p_fp32 - Recommended balance
  • large_640p_fp32 - Most accurate

OCR models:

  • pico_fp32 - Fastest
  • micro_fp32
  • small_fp32
  • medium_fp32 - Recommended
  • large_fp32 - Best accuracy

Backends:

  • cpu - Works everywhere
  • cuda - NVIDIA GPU (10-100x faster!)
  • directml - Windows GPU

πŸ“ Complete Example

from marearts_anpr import ma_anpr_detector_v14, ma_anpr_ocr_v14
from marearts_anpr import marearts_anpr_from_image_file
import os

# Load credentials
user_name = os.getenv('MAREARTS_ANPR_USERNAME')
serial_key = os.getenv('MAREARTS_ANPR_SERIAL_KEY')
signature = os.getenv('MAREARTS_ANPR_SIGNATURE')

# Initialize models
detector = ma_anpr_detector_v14(
    "medium_640p_fp32",
    user_name, serial_key, signature,
    backend="cpu",
    conf_thres=0.25,
    iou_thres=0.5
)

ocr = ma_anpr_ocr_v14("medium_fp32", "eup", user_name, serial_key, signature)

# Process European plate
print("Processing European plate...")
result = marearts_anpr_from_image_file(detector, ocr, "eu-plate.jpg")
print(result)

# Switch to Korean region
ocr.set_region('kr')
print("\nProcessing Korean plate...")
result = marearts_anpr_from_image_file(detector, ocr, "kr-plate.jpg")
print(result)

πŸ’‘ Key Takeaways

  • ✅ Three input methods: file, OpenCV, PIL
  • ✅ Dynamic region switching saves memory
  • ✅ Batch processing for efficiency
  • ✅ Multiple model sizes for different needs
  • ✅ GPU acceleration available

πŸ”— Try It Free!

No license yet? Try the free API (1000 requests/day):

ma-anpr test-api your-plate.jpg --region eup

Happy coding! πŸš—πŸ“Έ


Labels:

No comments:

Post a Comment