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.0.tar.gz (24.7 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.0-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for sinapsis_fast_alpr-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a52970acbde0abec2642167c1056d021a226aa821bce2cc34a478a0174c68f5e
MD5 205f3bf58017340b0eec53a6845e9f5a
BLAKE2b-256 8b01b50297d381aff5e892865811834224129406581b07185647d4ae26f20bd7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sinapsis_fast_alpr-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ca0cc6cca603e50f64ee68c8f34c57916e95fd320242d2eb2a1267e6634d1184
MD5 93af017699e4ebe4f2e0708aa8d6689a
BLAKE2b-256 c540496ccb1e3f4c857e24eaa31baae7af90a6de1de86470860ead67c6cafa7d

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