Methods

Note: Examples in this guide assume you have already configured LicensePlateTrackerConfig with model specifications. See Configuration Guide for complete setup details.

Methods Overview

Method
Purpose
Use Case

start_tracking_pipeline()

Real-time monitoring with automated alerting

Traffic monitoring, parking enforcement, security surveillance

predict_batch()

Stream processing with programmatic access

Custom analytics, logging, integration with other systems

find_plates_in_file()

Analyze local video files

Post-incident review, batch processing of footage

find_plates_in_clip()

Analyze cloud storage clips

Review alert clips, batch processing from S3


start_tracking_pipeline()

Run continuous real-time video monitoring with automated alerting, clip recording, and live streaming.

When to use: This is the primary method for production deployments where you need a fully automated system that runs continuously, handles alerts, saves video clips, and sends notifications. While you can attach a custom sink to access results programmatically, the main value of this method is the automated handling—use predict_batch() if programmatic result processing is your primary goal.

Signature

start_tracking_pipeline(
    frame_iterator: Optional[Iterable] = None,
    sink: Optional[SinkGizmo] = None
) -> Tuple[Composition, Watchdog]

Parameters

  • frame_iterator (Optional) - Custom frame source; if None, uses config.video_source

  • sink (Optional) - Custom output sink for results

Returns

Example: Traffic Monitoring

Monitor RTSP camera, save clips, and send notifications:

How the Pipeline Works

  1. Frame Acquisition - Read frame from video source

  2. License Plate Detection - Detect license plates with bounding boxes

  3. Object Tracking - Assign persistent track IDs to plates

  4. Plate Filtering - Apply quality filters (zone filtering, size thresholds)

  5. Plate Extraction - Crop license plate regions

  6. OCR Extraction - Extract text from license plates

  7. Bayesian Text Aggregation - Fuse OCR results across frames for improved accuracy

  8. Alert Evaluation - Check credence count and alert mode

  9. Clip Recording - Save video clips when alerts trigger

  10. Notification - Send alerts via configured channels

  11. Live Streaming - Output annotated video to display/RTSP


predict_batch()

Process video streams and return inference results for each frame with programmatic access.

When to use: Use this when you need fine-grained control over the processing pipeline. Unlike start_tracking_pipeline(), this method gives you access to results for every frame, allowing you to implement custom logic, logging, integration with other systems, or build your own alerting mechanisms.

Signature

Parameters

  • stream - Iterator yielding video frames as numpy arrays

Returns

Each result contains:

  • results - List of detection dictionaries with tracking data (access via result.results[i].get("track_id"))

  • license_plates property - List of LPRResult objects. See LPRResult Reference

Note: Tracking data (track_id, frame_id) is in the results list, not as properties of LPRResult. To correlate, use the same index for both lists.

Example: Custom Logging

Process video and log all license plate detections:


find_plates_in_file()

Analyze local video files to find and track all license plates, optionally creating annotated output.

When to use: This is the go-to method for offline analysis of recorded video. Use it for post-incident review, batch processing local video files, or analyzing archived footage. The method automatically handles tracking, applies Bayesian text aggregation for improved OCR accuracy, and produces annotated videos for easy review.

Signature

Parameters

  • file_path (str) - Path to input video file

  • save_annotated (bool) - Whether to save annotated video (default: True)

  • output_video_path (Optional[str]) - Path for annotated output video; if None, no video is saved

Returns

  • Dict[int, PlateOCRResult] - Dictionary mapping track IDs to plate OCR data:

    • Each PlateOCRResult object contains the aggregated plate number and OCR score

Example: Analyze Video File


find_plates_in_clip()

Analyze video clips from object storage (S3 or local), similar to find_plates_in_file() but for cloud/storage-based clips.

When to use: Use this to review video clips saved by start_tracking_pipeline() or stored in S3/object storage. It's particularly useful for reviewing alert clips generated by the automated pipeline, allowing you to verify detections and analyze incidents from cloud-stored footage.

Signature

Parameters

  • clip_object_name (str) - Name of video clip in object storage

  • save_annotated (bool) - Whether to save annotated video back to storage (default: True)

Returns

  • Dict[int, PlateOCRResult] - Dictionary mapping track IDs to plate OCR data (same as find_plates_in_file())

Requirements

  • clip_storage_config must be configured in LicensePlateTrackerConfig

Example: Review Alert Clips

Process license plate clips from cloud storage:

Note: Annotated videos are saved with _annotated suffix in the same storage location.

Complete Example

Last updated

Was this helpful?