Reference
Available Models¶
See available detection models in open-image-models and OCR models in fast-plate-ocr.
FastALPR¶
FastALPR package.
ALPR
¶
Automatic License Plate Recognition (ALPR) system class.
This class combines a detector and an OCR model to recognize license plates in images.
Source code in fast_alpr/alpr.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
__init__(detector=None, ocr=None, detector_model='yolo-v9-t-384-license-plate-end2end', detector_conf_thresh=0.4, detector_providers=None, detector_sess_options=None, ocr_model='european-plates-mobile-vit-v2-model', ocr_device='auto', ocr_providers=None, ocr_sess_options=None, ocr_model_path=None, ocr_config_path=None, ocr_force_download=False)
¶
Initialize the ALPR system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
detector
|
BaseDetector | None
|
An instance of BaseDetector. If None, the DefaultDetector is used. |
None
|
ocr
|
BaseOCR | None
|
An instance of BaseOCR. If None, the DefaultOCR is used. |
None
|
detector_model
|
PlateDetectorModel
|
The name of the detector model or a PlateDetectorModel enum instance. Defaults to "yolo-v9-t-384-license-plate-end2end". |
'yolo-v9-t-384-license-plate-end2end'
|
detector_conf_thresh
|
float
|
Confidence threshold for the detector. |
0.4
|
detector_providers
|
Sequence[str | tuple[str, dict]] | None
|
Execution providers for the detector. |
None
|
detector_sess_options
|
SessionOptions
|
Session options for the detector. |
None
|
ocr_model
|
OcrModel | None
|
The name of the OCR model from the model hub. This can be none and
|
'european-plates-mobile-vit-v2-model'
|
ocr_device
|
Literal['cuda', 'cpu', 'auto']
|
The device to run the OCR model on ("cuda", "cpu", or "auto"). |
'auto'
|
ocr_providers
|
Sequence[str | tuple[str, dict]] | None
|
Execution providers for the OCR. If None, the default providers are used. |
None
|
ocr_sess_options
|
SessionOptions | None
|
Session options for the OCR. If None, default session options are used. |
None
|
ocr_model_path
|
str | PathLike | None
|
Custom model path for the OCR. If None, the model is downloaded from the hub or cache. |
None
|
ocr_config_path
|
str | PathLike | None
|
Custom config path for the OCR. If None, the default configuration is used. |
None
|
ocr_force_download
|
bool
|
Whether to force download the OCR model. |
False
|
Source code in fast_alpr/alpr.py
draw_predictions(frame)
¶
Draws detections and OCR results on the frame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frame
|
ndarray | str
|
The original frame or image path. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
The frame with detections and OCR results drawn. |
Source code in fast_alpr/alpr.py
predict(frame)
¶
Returns all recognized license plates from a frame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frame
|
ndarray | str
|
Unprocessed frame (Colors in order: BGR) or image path. |
required |
Returns:
Type | Description |
---|---|
list[ALPRResult]
|
A list of ALPRResult objects containing detection and OCR results. |
Source code in fast_alpr/alpr.py
ALPRResult
dataclass
¶
BaseDetector
¶
Bases: ABC