Skip to content

Commit d785b78

Browse files
committed
no gpu demo for win os added
1 parent e8c6a09 commit d785b78

17 files changed

+151
-141
lines changed

README.md

+65-13
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# LPReditor_ANPR_Lib
1+
*# LPReditor_ANPR_Lib
22
C library that performs license plate recognition.
33

44
*Deep learning number plate recognition engine, based on ![YOLOv5](https://github.com/ultralytics/yolov5) and ![ONNX](https://github.com/onnx/onnx). Operates on any latin license plate.*
5-
- [LPReditor_ANPR_Lib](#lpreditor_anpr_lib)
65
- [C API](#c-api)
76
- [Building the API](#building-the-api)
87
- [(Common) Step 1 : Install !OpenCV and CUDA & cuDNN (Optional but recommended if you want to use CUDA Execution Provider)](#common-step-1--install--and-cuda--cudnn-optional-but-recommended-if-you-want-to-use-cuda-execution-provider)
@@ -19,8 +18,10 @@ C library that performs license plate recognition.
1918
- [Usage](#usage)
2019
- [API Documentation](#api-documentation)
2120
- [*init_yolo_detector*](#init_yolo_detector)
21+
- [*init_plates_classifer*](#init_plates_classifer)
2222
- [*detect_with_lpn_detection*](#detect_with_lpn_detection)
2323
- [*close_detector*](#close_detector)
24+
- [*close_plates_types_classifier*](#close_plates_types_classifier)
2425
- [sample_cpp](#sample_cpp)
2526
- [Building sample_cpp](#building-sample_cpp)
2627
- [Binary release](#binary-release)
@@ -45,7 +46,7 @@ The code is standard c++ and relies on ![ONNXRuntime](https://github.com/microso
4546
#### (Common) Step 1 : Install ![OpenCV](https://github.com/opencv/opencv) and CUDA & cuDNN (Optional but recommended if you want to use CUDA Execution Provider)
4647

4748
The installation process of CUDA is quite straightforward. You can Install CUDA v11.0 from
48-
![here](https://developer.nvidia.com/cuda-11.0-download-archive). Next, install cuDNN by downloading the installer from ![here](https://developer.nvidia.com/rdp/cudnn-archive). You also need to download models files, that er too large to be accepted by my github account. Models are available on my drive account here ![here](https://drive.google.com/drive/folders/1NIU2EYfdzRbtgHvdRUY0yJmUzANIqEP9?usp=sharing). Download models.zip file and unzip in /data/ folder.
49+
[here](https://developer.nvidia.com/cuda-11.0-download-archive). Next, install cuDNN by downloading the installer from [here](https://developer.nvidia.com/rdp/cudnn-archive). You also need to download models files, that er too large to be accepted by my github account. Models are available on my drive account here [here](https://drive.google.com/drive/folders/1NIU2EYfdzRbtgHvdRUY0yJmUzANIqEP9?usp=sharing). Download models.zip file and unzip in /data/ folder.
4950
### On Windows :
5051
#### Step 2 : ![onnxruntime-win-x64-1.x.y](https://github.com/microsoft/onnxruntime/releases)
5152
Download onnxruntime-win-x64-1.x.y.zip and decompress somewhere.
@@ -69,7 +70,7 @@ The use of the library decomposes in three distinct steps. At first, engine init
6970
This id must be passed, as a parameter, to the two others functions. Second, call the *detect_with_lpn_detection* function, to recognize license plates in images. Parameters of the *detect_with_lpn_detection* function are :
7071

7172
- 4 parameters, to access the image, (preloaded) in memory.
72-
- the ids of models returned by *init_yolo_detector*.
73+
- the ids of models returned by *init_yolo_detector* and *init_plates_classifer*.
7374
- a pointer to a (preallocated) c string (filled, in return, with the license plate number string)
7475

7576
Third, when reading images is ended, call the *close_detector* to free the memory, consumed by the detector (important : pass, as parameter, the id returnned by *init_yolo_detector*).
@@ -142,7 +143,7 @@ session_closed = close_plates_types_classifier(id_plates_types_classifier//id :
142143
### *init_yolo_detector*
143144
```javascript
144145
/**
145-
@brief initializes a new detector, by loading its model file and returns its unique id. The repo comes with two models namely lpreditor_anpr_focused_on_lp and lpreditor_anpr_global_view. So you have to call this function twice to initialize both models (note that it is possible, but not a good idea, to initialize just one model).
146+
@brief initializes a new detector, by loading its model file and returns its unique id. The repo comes with two models namely lpreditor_anpr_focused_on_lp and lpreditor_anpr_global_view (these models have to be downloaded from [google drive] (https://drive.google.com/drive/folders/1NIU2EYfdzRbtgHvdRUY0yJmUzANIqEP9?usp=sharing)). So you have to call this function twice to initialize both models (note that it is possible, but not a good idea, to initialize just one model).
146147
@param model_file : c string model filename
147148
@param len : length of the model filename
148149
@return the id of the new detector
@@ -157,6 +158,22 @@ size_t init_yolo_detector(size_t len, const char* model_file)
157158
```
158159
159160
161+
### *init_plates_classifer*
162+
```javascript
163+
/**
164+
@brief initializes a new plates type classifier by loading its model file and returns its unique id
165+
@param model_file : c string model filename (must be allocated by the calling program)
166+
@param len : length of the model filename
167+
@return the id of the new detector
168+
@see
169+
*/
170+
extern "C"
171+
#ifdef _WINDOWS
172+
__declspec(dllexport)
173+
#endif //_WINDOWS
174+
size_t init_plates_classifer(size_t len, const char* model_file)
175+
176+
```
160177
### *detect_with_lpn_detection*
161178
```javascript
162179
/**
@@ -174,20 +191,38 @@ size_t init_yolo_detector(size_t len, const char* model_file)
174191
@param lpn : the resulting license plate number as a c string, allocated by the calling program.
175192
@return true upon success
176193
*/
194+
195+
196+
/**
197+
@brief detect lpn in frame. This function uses a two stage detection method that requires two models.
198+
please make sure you have initialized the lpreditor_anpr_global_view model in the init_yolo_detector function (see sample_cpp for uses examples).
199+
@param width : width of source image
200+
@param width : width of source image
201+
@param height : height of source image
202+
@param pixOpt : pixel type : 1 (8 bpp greyscale image) 3 (RGB 24 bpp image) or 4 (RGBA 32 bpp image)
203+
@param *pbData : source image bytes buffer
204+
@param step Number of bytes each matrix row occupies. The value should include the padding bytes at
205+
the end of each row, if any..See sample_cpp for a use case.
206+
@param id_global_view : unique id to a model initialized in init_yolo_detector function. See init_yolo_detector function.
207+
@param id_focused_on_lp : unique id to a model initialized in init_yolo_detector function. See init_yolo_detector function.
208+
@param id_plates_types_classifier : unique id to a model initialized in init_plates_classifer function. See init_plates_classifer function.
209+
@param lpn_len : length of the preallocated c string to store the resulting license plate number.
210+
@param lpn : the resulting license plate number as a c string, allocated by the calling program.
211+
@return
212+
@see
213+
*/
177214
extern "C"
178215
#ifdef _WINDOWS
179216
__declspec(dllexport)
180217
#endif //_WINDOWS
181-
bool detect_with_lpn_detection
182-
(const int width,//width of image
183-
const int height,//height of image i.e. the specified dimensions of the image
184-
const int pixOpt,// pixel type : 1 (8 bpp greyscale image) 3 (RGB 24 bpp image) or 4 (RGBA 32 bpp image)
185-
void* pbData, size_t step// source image bytes buffer
186-
, size_t id, size_t lpn_len, char* lpn)
218+
bool two_stage_lpr_plates_type_detection
219+
(const int width,//width of image
220+
const int height,//height of image i.e. the specified dimensions of the image
221+
const int pixOpt,// pixel type : 1 (8 bpp greyscale image) 3 (RGB 24 bpp image) or 4 (RGBA 32 bpp image)
222+
void* pbData, size_t step// source image bytes buffer
223+
, size_t id_global_view, size_t id_focused_on_lp, size_t id_plates_types_classifier, size_t lpn_len, char* lpn)
187224

188225
```
189-
190-
191226
### *close_detector*
192227
```javascript
193228
/**
@@ -202,6 +237,22 @@ __declspec(dllexport)
202237
#endif //_WINDOWS
203238
bool close_detector(size_t id)
204239

240+
```
241+
242+
### *close_plates_types_classifier*
243+
```javascript
244+
/**
245+
@brief call this func once you have finished with the classifier --> to free heap allocated memeory
246+
@param id : unique interger to identify the classifier to be freed
247+
@return true upon success
248+
@see
249+
*/
250+
extern "C"
251+
#ifdef _WINDOWS
252+
__declspec(dllexport)
253+
#endif //_WINDOWS
254+
bool close_plates_types_classifier(size_t id)
255+
205256
```
206257
# sample_cpp
207258
The repo comes with a example, called sample_cpp. It needs ![OpenCV](https://github.com/opencv/opencv) to load images.
@@ -286,3 +337,4 @@ One error on one character means that the numberplate, read by the engine, diffe
286337
You can make the test yourself, using the sample_cpp demo project (with command line args like above).
287338
288339
340+
*

0 commit comments

Comments
 (0)