Skip to main content

Library to parse and validate Vietnamese vehicle plate

Project description

https://badgen.net/pypi/v/biensoxe

Library to validate and parse Vietnamese vehicle plate.

This library is not a computer-vision-based license plate recognition software. It instead is used for validating output of such computer vision software. Imagine that you use camera to track all cars coming in and out off your parking lot, but you don’t want to save false result (due to wrong angle of camera, for example), you can use this library to check and remove them.

Install

pip3 install biensoxe

Usage

Call VietnamVehiclePlate.from_string, passing the number string, to create VietnamVehiclePlate object.

>>> from biensoxe import VietnamVehiclePlate

>>> VietnamVehiclePlate.from_string('44A-112.23')
VietnamVehiclePlate(compact='44A11223', vehicle_type=<VehicleType.DOMESTIC_AUTOMOBILE: 1>,
series='A', order='11223', locality='44', dip_country=None)

>>> VietnamVehiclePlate.from_string('41-291-NG-01')
VietnamVehiclePlate(vehicle_type=<VehicleType.DIPLOMATIC: 9>, series='NG', order='01', locality='41', dip_country='291')

The method raises ValueError if the string could not be parsed.

To format the plate number as in daily life, pass VietnamVehiclePlate to str:

>>> plate = VietnamVehiclePlate.from_string('72E101130')

>>> plate
VietnamVehiclePlate(compact='72E101130', vehicle_type=<VehicleType.DOMESTIC_MOTORCYCLE_50_TO_175CC: 3>, series='E1', order='01130', locality='72', dip_country=None)

>>> str(plate)
'72-E1 011.30'

Django

This library provides a field type, VietnamVehiclePlateField, for Django model. The field will return value as VietnamVehiclePlate object. Here is example:

from biensoxe.django import VietnamVehiclePlateField

def default_plate_number():
    return VietnamVehiclePlate.from_string('10A 00001')

class Vehicle(models.Model):
    plate_number = VietnamVehiclePlateField(max_length=20, default=default_plate_number, unique=True)

def __str__(self):
    return str(self.plate_number) or self.pk

Note that this field stores value internally as PostgeSQL CIText data type, so you can only use this field with PostgreSQL. You also need to activate CITextExtension yourself.

Credit

Brought to you by Nguyễn Hồng Quân.

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

biensoxe-0.8.5.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

biensoxe-0.8.5-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file biensoxe-0.8.5.tar.gz.

File metadata

  • Download URL: biensoxe-0.8.5.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.2 Linux/5.4.0-33-generic

File hashes

Hashes for biensoxe-0.8.5.tar.gz
Algorithm Hash digest
SHA256 60de69850cfc81036a62e93344d22906cc6ee5768418d846a7b0171390147168
MD5 cc5e8a37ba14347ef3b1d2a5f8fd4a8f
BLAKE2b-256 2168b66b4cabc8f1aafc4163b924bbff6b090be71b77e145b9fa1950824785e0

See more details on using hashes here.

File details

Details for the file biensoxe-0.8.5-py3-none-any.whl.

File metadata

  • Download URL: biensoxe-0.8.5-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.2 Linux/5.4.0-33-generic

File hashes

Hashes for biensoxe-0.8.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a7f3d3aedd14647304ee2aa07d2bdf9cc3e0de3c52d13629d1469ad24f537697
MD5 fa2c86d870e78fc7689564309dc470b8
BLAKE2b-256 bf58121c0c92bc5284893d5eb459e2c0cd3382297fde49240d633e833c7dbe2c

See more details on using hashes here.

Supported by

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