Skip to main content

Fast ALPR license plate recognition

Project description

sp




Sinapsis Fast ALPR

Templates for Automatic License Plate Recognition and speed calculation.

🐍 Installation🚀 Features📚 Example usage📙 Documentation🔍 License

The sinapsis-fast-alpr module provides templates for calculation of vehicle speed and license plate recognition in videos, through Fast ALPR and RFDETR.

🐍 Installation

Install using your package manager of choice. We encourage the use of uv

uv pip install sinapsis-fast-alpr

or wiht raw pip

pip install sinapsis-fast-alpr

[!IMPORTANT] Templates in sinapsis-fast-alpr package may require extra dependencies. For development, we recommend installing the package with all the optional dependencies:

uv pip install sinapsis-fast-alpr[all] --extra-index-url https://pypi.sinapsis.tech

or

pip install sinapsis-fast-alpr[all] --extra-index-url https://pypi.sinapsis.tech

🚀 Features

Templates Supported

The Sinapsis Fast ALPR module provides the following templates for Speed Calculation and License Plate Recognition.

  • ClassFilter: Limits object detections to certain given classes.
  • FastALPR: Runs fast-alpr pipeline to detect and recognize liense plates.
  • PerspectiveTransform: Transforms the perspective of a camera into a rectangle to compensate for the view and works along with ObjectSpeedCalculation template.
  • ObjectSpeedCalculation: Approximates the speed of objects detected in video.

📚 Example usage

The example available in sinapsis-fast-alpr/src/sinapsis_fast_alpr/configs/speed_calculation.yaml demonstrates how to use the sinapsis-fast-alpr templates. This configuration defines an agent and a sequence of templates to run fast-alpr and speed calculation.

To adjust the configuration details for your own video, you can use the pick-coordinates and meters-per-pixel commands to obtain the values to add in the PerspectiveTransform and ObjectSpeedCalculation templates.

  • Use uv run pick-coordinates [path to your video] and pick four points of the road to compensate the perspective. The script will give the values for source_points that can be added to PerspectiveTransform

  • Use uv run meters-per-pixel [path to your video] and pick two points on the road which represent a meter in real-life distance. The script will give a meters_per_pixel value that can be added to ObjectSpeedCalculation

  • You can substitute the values for frames per second, thresholds, detector models according to your provided video and requirements.

Config file
agent:
  name: speed_calculation
  attributes:
    agent_mode: generator

templates:
- template_name: InputTemplate
  class_name: InputTemplate
  attributes: {}

- template_name: Video
  class_name: VideoReaderCV2
  template_input: InputTemplate
  attributes:
    root_dir: path to root dir
    video_file_path: path to video
    batch_size: 1
    device: cpu
    loop_forever: true


- template_name: Inference
  class_name: RFDETRInference
  template_input: Video
  attributes:
    model_params:
      encoder: dinov2_windowed_small
      num_classes: 90
      pretrain_weights: rf-detr-base.pth
      device: cuda
      resolution: 560
    threshold: 0.6

- template_name: Filter
  class_name: ClassFilter
  template_input: Inference
  attributes: {}


- template_name: Track
  class_name: ByteTrack
  template_input: Filter
  attributes:
    track_activation_threshold: 0.2
    minimum_matching_threshold: 0.5
    minimum_consecutive_frames: 1
    frame_rate: 25

- template_name: Transform
  class_name: DetectionPerspectiveTransform
  template_input: Track
  attributes:
    source_points: [[806, 291], [1237, 291], [1562, 931], [325, 920]]

- template_name: Speed
  class_name: ObjectSpeedCalculation
  template_input: Transform
  attributes:
    fps: 25
    meters_per_pixel: 0.06
    speed_limit: 20

- template_name: License
  class_name: FastALPR
  template_input: Speed
  attributes:
    detector_model: yolo-v9-s-608-license-plate-end2end
    ocr_model: cct-xs-v1-global-model
    detection_treshold: 0.6
    ocr_threshold: 0.6

- template_name: Drawer
  class_name: BBoxDrawer
  template_input: License
  attributes:
    overwrite: true
    randomized_color: false
    draw_confidence: true
    draw_extra_labels: true
    text_style:
      font: 0
      font_scale: 0.5
      thickness: 2
    draw_classification_label: true
    classification_label_position: top_right
    text_box_to_border_offset: 0.01

- template_name: VideoWriterCV2
  class_name: VideoWriterCV2
  template_input: Drawer
  attributes:
    root_dir: .
    destination_path: results/video.mp4
    height: -1
    width: -1
    fps: 25
    codec: mp4v
    save_image_batch: false

To run the agent, use:

uv run sinapsis run sinapsis-fast-alpr/src/sinapsis_fast_alpr/configs/speed_calculation.yaml

📙 Documentation

Documentation is available on the sinapsis website

Tutorials for different projects within sinapsis are available at sinapsis tutorials page

🔍 License

The templates in this project are licensed under the AGPLv3 license, which encourages open collaboration and sharing. For more details, please refer to the LICENSE file.

The command line interface and pipelines in this project are licensed under the MIT license, which allows for unrestricted use of the software and encourages open collaboration. For more details please refer to the LICENSE file

For commercial use, please refer to our official Sinapsis website for information on obtaining a commercial license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sinapsis_fast_alpr-0.1.1.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sinapsis_fast_alpr-0.1.1-py3-none-any.whl (26.9 kB view details)

Uploaded Python 3

File details

Details for the file sinapsis_fast_alpr-0.1.1.tar.gz.

File metadata

  • Download URL: sinapsis_fast_alpr-0.1.1.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.16

File hashes

Hashes for sinapsis_fast_alpr-0.1.1.tar.gz
Algorithm Hash digest
SHA256 86193921208522d89ee31674c5cc275a776167352db380832e761bc8950b591d
MD5 b645001f566ef3d98622c7d2e376bfda
BLAKE2b-256 6c28af30f0e15710ea4147a5a97566854ff2bd7c5a016340aac14c613ac8ec79

See more details on using hashes here.

File details

Details for the file sinapsis_fast_alpr-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for sinapsis_fast_alpr-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1480e91751a043e8375e151b2c5ab56a188748234a6e5f7e7dc3a48bdb9fe8bb
MD5 7b4d78b90720ee7049d3dc08d7d37824
BLAKE2b-256 62482ddc8df797f752bed68fa54dd311771ee307e6fee435650aa41f8b6e7485

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page