# LP Tracker

## What is LicensePlateTracker?

`LicensePlateTracker` processes video streams with real-time license plate detection, tracking, and recognition. It maintains persistent vehicle identities across frames and uses Bayesian multi-frame text aggregation to improve OCR accuracy.

## When to Use LicensePlateTracker

Choose `LicensePlateTracker` when you need to:

* Process live camera feeds or RTSP streams in real-time
* Track vehicles with persistent IDs across video frames
* Improve OCR accuracy via Bayesian multi-frame text fusion
* Generate alerts and notifications for detected plates
* Save video clips with detected vehicles

**For simple batch image processing without temporal tracking**, use [LicensePlateRecognizer](https://docs.degirum.com/vehicle-analytics/guides/overview) instead.

## Core Concepts

### Configuration

All settings are controlled through `LicensePlateTrackerConfig`:

```python
import degirum_vehicle

config = degirum_vehicle.LicensePlateTrackerConfig(
    license_plate_detection_model_spec=detection_spec,  # Detection model
    license_plate_ocr_model_spec=ocr_spec,             # OCR model
    video_source="highway.mp4",                        # Video source
    live_stream_mode="LOCAL",                          # Display mode
)

tracker = degirum_vehicle.LicensePlateTracker(config)
```

See [Configuration Guide](https://docs.degirum.com/vehicle-analytics/guides/overview-1/configuration) for all options.

### Pipeline Architecture

The tracker uses a multi-stage streaming pipeline:

1. **Video Source** - Reads from camera, file, or RTSP stream
2. **License Plate Detection** - Detects plate regions in each frame
3. **Vehicle Tracking** - Tracks vehicles across frames with unique IDs
4. **Cropping** - Extracts detected plate regions
5. **OCR Recognition** - Runs text recognition on cropped plates
6. **Bayesian Fusion** - Aggregates OCR results across multiple frames per vehicle track
7. **Annotation** - Overlays tracking IDs and plate text on video
8. **Output** - Display, save to file, or stream via RTSP

The Bayesian fusion uses exponential moving average of character probabilities to improve accuracy over single-frame recognition.

### Key Features

**Vehicle Tracking**

* Unique track IDs for each vehicle
* Track persistence across frames
* Zone-based filtering (optional)
* Track trail visualization

**Multi-Frame Bayesian Text Aggregation**

* Combines OCR results across multiple frames
* Exponential moving average of character probabilities
* Improved accuracy vs. single-frame recognition
* Confidence scoring per track

**Video Processing**

* Live camera feeds (webcam, IP camera)
* Video files (MP4, AVI, etc.)
* RTSP streams
* Real-time display or RTSP streaming output

**Event Notifications**

* Configurable alert conditions
* Apprise notification support (email, Slack, Discord, etc.)
* Video clip storage with alerts

## Methods

`LicensePlateTracker` provides methods for video processing:

* [**start\_tracking\_pipeline()**](https://docs.degirum.com/vehicle-analytics/guides/methods#start_tracking_pipeline) - Start real-time tracking pipeline
* [**predict\_batch()**](https://docs.degirum.com/vehicle-analytics/guides/methods#predict_batch) - Process video stream and return results
* [**find\_plates\_in\_file()**](https://docs.degirum.com/vehicle-analytics/guides/methods#find_plates_in_file) - Analyze entire video file
* [**find\_plates\_in\_clip()**](https://docs.degirum.com/vehicle-analytics/guides/methods#find_plates_in_clip) - Analyze video from object storage

See [Methods Reference](https://docs.degirum.com/vehicle-analytics/guides/overview-1/methods) for complete API documentation with examples.
