You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

335 lines
10 KiB
Markdown

2 years ago
![logo_t](./images/hyperlpr_logo.png)
7 years ago
2 years ago
## HyperLPR3 - High Performance License Plate Recognition Framework.
8 years ago
2 years ago
#### [![1](https://badge.fury.io/py/hyperlpr3.svg "title")](https://pypi.org/project/hyperlpr3/)[![1](https://img.shields.io/pypi/pyversions/hyperlpr3.svg "title")](https://pypi.org/manage/project/hyperlpr3/releases/)
[中文文档](README_CH.md)
8 years ago
2 years ago
### Demo APP Installation
- Android APP[Scan QR Code](http://fir.tunm.top/hyperlpr)
### Quick Installation
7 years ago
`python -m pip install hyperlpr3`
2 years ago
###### supportpython3, Windows, Mac, Linux, Raspberry Pi。
7 years ago
7 years ago
7 years ago
###### 720p cpu real-time (st on MBP r15 2.2GHz haswell).
7 years ago
2 years ago
#### Quick Test
```bash
2 years ago
# image url
2 years ago
lpr3 sample -src https://koss.iyong.com/swift/v1/iyong_public/iyong_2596631159095872/image/20190221/1550713902741045679.jpg
2 years ago
# image path
lpr3 sample -src images/test_img.jpg -det high
```
2 years ago
#### How to Use
7 years ago
```python
2 years ago
# import opencv
7 years ago
import cv2
2 years ago
# import hyperlpr3
import hyperlpr3 as lpr3
2 years ago
# Instantiate object
catcher = lpr3.LicensePlateCatcher()
2 years ago
# load image
image = cv2.imread("images/test_img.jpg")
2 years ago
# print result
print(catcher(image))
```
2 years ago
#### Start the WebAPI service
```bash
2 years ago
# start server
lpr3 rest --port 8715 --host 0.0.0.0
7 years ago
```
2 years ago
Path to open SwaggerUI after startup[http://localhost:8715/api/v1/docs](http://localhost:8715/api/v1/docs) View and test the online Identification API service:
![swagger_ui](./images/swagger-ui.png)
8 years ago
7 years ago
#### Q&A
2 years ago
QWhether the accuracy of android in the project is consistent with that of apk-demo
7 years ago
2 years ago
APlease compile or download the Android shared library from the release and copy it to Prj-Android for testing。
7 years ago
2 years ago
QSource of training data for license plates
7 years ago
2 years ago
ASince the license plate data used for training involves legal privacy and other issues, it cannot be provided in this project. Open more big data sets [CCPD](https://github.com/detectRecog/CCPD) registration dataset。
7 years ago
2 years ago
QProvision of training code
7 years ago
2 years ago
AThe resources provide the old training code, and the training methods for HyperLPR3 will be sorted out and presented later。
7 years ago
2 years ago
#### Resources
7 years ago
2 years ago
- [HyperLPR3车牌识别-五分钟搞定: 中文车牌识别光速部署与使用](https://blog.csdn.net/weixin_40193776/article/details/129258107)
2 years ago
2 years ago
- [HyperLPR3车牌识别-Android-SDK光速部署与使用](https://blog.csdn.net/weixin_40193776/article/details/129394240)
2 years ago
2 years ago
- [HyperLPR3车牌识别-Linux/MacOS使用C/C++库编译](https://blog.csdn.net/weixin_40193776/article/details/129295679)
2 years ago
- [HyperLPR3车牌识别-Android使用SDK编译与部署](https://blog.csdn.net/weixin_40193776/article/details/129354938)
2 years ago
2 years ago
- To be added... Contributions welcome
2 years ago
2 years ago
#### Other Versions
2 years ago
2 years ago
- [HyperLPRv1](https://github.com/szad670401/HyperLPR/tree/v1)
6 years ago
2 years ago
- [HyperLPRv2](https://github.com/szad670401/HyperLPR/tree/v2)
8 years ago
### TODO
2 years ago
- Support for rapid deployment of WebApi services
- Support multiple license plates and double layers
- Support large Angle license plate
- Lightweight recognition model
7 years ago
2 years ago
### Specialty
8 years ago
2 years ago
- 720p faster, single core Intel 2.2G CPU (MaBook Pro 2015) average recognition time is less than 100ms
- End-to-end license plate recognition does not require character segmentation
- The recognition rate is high, and the accuracy of the entrance and exit scene is about 95%-97%
- Support cross-platform compilation and rapid deployment
7 years ago
2 years ago
### Matters Need Attention:
8 years ago
2 years ago
- The C++ and Python implementations of this project are separate
- When compiling C++ projects, OpenCV 4.0 and MNN 2.0 must be used, otherwise it will not compile
- Android project compilation ndk as far as possible to use version 21
2 years ago
### Python Dependency
- opencv-python (>3.3)
- onnxruntime (>1.8.1)
- fastapi (0.92.0)
- uvicorn (0.20.0)
- loguru (0.6.0)
- python-multipart
- tqdm
- requests
2 years ago
### Cross-platform support
2 years ago
2 years ago
#### Platform
2 years ago
- Linux: x86、Armv7、Armv8
- MacOS: x86
- Android: arm64-v8a、armeabi-v7a
2 years ago
#### Embedded Development Board
2 years ago
- Rockchip: rv1109rv1126(RKNPU)
2 years ago
### CPP Dependency
2 years ago
- Opencv 4.0 above
- MNN 2.0 above
2 years ago
### C/C++ Compiling Dependencies
8 years ago
2 years ago
Compiling C/C++ projects requires the use of third-party dependency libraries. After downloading the library, unzip it, and put it into the root directory (the same level as CMakeLists.txt) by copying or soft linking.[baidu drive](https://pan.baidu.com/s/138O2bSlPN0H81OYP6zc3yQ) code: 5duf
8 years ago
2 years ago
### Linux/Mac Shared Library Compilation
2 years ago
- Need to place or link dependencies in the project root (same level as CMakeLists.txt)
8 years ago
```bash
2 years ago
# execute the script
sh command/build_release_linux_share.sh
8 years ago
```
2 years ago
Compiled to the **build/linux/install/hyperlpr3** dirWhich contains
- include - header file
- lib - shared dir
- resource - test-images and models dir
2 years ago
Copy the files you need into your project
2 years ago
### Linux/Mac Compiling the Demo
8 years ago
2 years ago
- You need to complete the compilation action of the previous stepAnd ensure that the compilation is successful and the compiled file is placed in the root directory: **build/linux/install/hyperlpr3**
- Go to the **Prj-Linux** folder
```bash
2 years ago
# go to Prj-linux
cd Prj-Linux
2 years ago
# exec sh
sh build.sh
```
2 years ago
The executable program is generated after compilation: **PlateRecDemo**and Run the program
```bash
2 years ago
# go to build
cd build/
2 years ago
# first param models dir, second param image path
./PlateRecDemo ../hyperlpr3/resource/models/r2_mobile ../hyperlpr3/resource/images/test_img.jpg
```
2 years ago
### Linux/Mac Quick Use SDK Code Example
```C
2 years ago
// Load image
cv::Mat image = cv::imread(image_path);
2 years ago
// Create a ImageData
HLPR_ImageData data = {0};
2 years ago
data.data = image.ptr<uint8_t>(0); // Setting the image data flow
data.width = image.cols; // Setting the image width
data.height = image.rows; // Setting the image height
data.format = STREAM_BGR; // Setting the current image encoding format
data.rotation = CAMERA_ROTATION_0; // Setting the current image corner
// Create a Buffer
P_HLPR_DataBuffer buffer = HLPR_CreateDataBuffer(&data);
2 years ago
// Configure license plate recognition parameters
HLPR_ContextConfiguration configuration = {0};
2 years ago
configuration.models_path = model_path; // Model folder path
configuration.max_num = 5; // Maximum number of license plates
configuration.det_level = DETECT_LEVEL_LOW; // Level of detector
configuration.use_half = false;
2 years ago
configuration.nms_threshold = 0.5f; // Non-maxima suppress the confidence threshold
configuration.rec_confidence_threshold = 0.5f; // License plate number text threshold
configuration.box_conf_threshold = 0.30f; // Detector threshold
configuration.threads = 1;
2 years ago
// Instantiating a Context
P_HLPR_Context ctx = HLPR_CreateContext(&configuration);
2 years ago
// Query the Context state
HREESULT ret = HLPR_ContextQueryStatus(ctx);
if (ret != HResultCode::Ok) {
printf("create error.\n");
return -1;
}
HLPR_PlateResultList results = {0};
2 years ago
// Execute LPR
HLPR_ContextUpdateStream(ctx, buffer, &results);
for (int i = 0; i < results.plate_size; ++i) {
2 years ago
// Getting results
std::string type;
if (results.plates[i].type == HLPR_PlateType::PLATE_TYPE_UNKNOWN) {
2 years ago
type = “Unknown";
} else {
type = TYPES[results.plates[i].type];
8 years ago
}
printf("<%d> %s, %s, %f\n", i + 1, type.c_str(),
results.plates[i].code, results.plates[i].text_confidence);
8 years ago
}
2 years ago
// Release Buffer
HLPR_ReleaseDataBuffer(buffer);
2 years ago
// Release Context
HLPR_ReleaseContext(ctx);
8 years ago
```
2 years ago
### Android: Compile the Shared Library
- The first step is to install third-party dependencies
2 years ago
- You need to prepare NDKS and configure environment variables: $ANDROID_NDK
- Supports cross-compilation on Linux/MacOS
```bash
2 years ago
# execute the script
sh command/build_release_android_share.sh
```
2 years ago
Compiled to the: **build/release_android/**Which contains
- arm64-v8a - 64bit shard library
- armeabi-v7a - 32bit shard library
2 years ago
After compilingCopy**arm64-v8a**and**armeabi-v7a** dirs to **Prj-Android/hyperlpr3/libs**And compile the **Prj-Android** project to use.
### Compile with Docker
If you need to compile with docker, we provide a few ways to compile:
#### 1. Compile the Linux-x86 Shared Library using Docker
You need to install docker and docker-composeBuild Image for **hyperlpr_build**:
```Bash
docker build -t hyperlpr_build .
```
Start compiling the shared library:
```Bash
docker-compose up build_linux_x86_shared_lib
```
Build dir: **build/linux**
### Android SDK Demo
We have provided a demo project from the Android SDK source: [hyperlpr3-android-sdk](https://github.com/HyperInspire/hyperlpr3-android-sdk.git)You can compile the shared library and use the project as needed.
### Quick to use in Android
If you need to quickly integrate our sdk in your own Android project, then you can add the following dependency to your project's build.gradle:
- Step 1. Add the JitPack repository to your build file.Add it in your root build.gradle at the end of repositories:
2 years ago
```Java
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```
- Step 2. Add the dependency
2 years ago
```Java
dependencies {
2 years ago
implementation 'com.github.HyperInspire:hyperlpr3-android-sdk:1.0.3'
}
```
- Step 3. Use hyperlpr in your application
2 years ago
```Java
// Initialization, which can be performed only once, is usually performed at program initialization
HyperLPR3.getInstance().init(this, new HyperLPRParameter());
// exec recognition
Plate[] plates = HyperLPR3.getInstance().plateRecognition(bitmap, HyperLPR3.CAMERA_ROTATION_0, HyperLPR3.STREAM_BGRA);
```
Know more about: **[Prj-Android](./Prj-Android)**
8 years ago
2 years ago
### License Plate Type is Supported(Chinese)
8 years ago
#### 支持
7 years ago
- [x] 单行蓝牌
- [x] 单行黄牌
- [x] 新能源车牌
- [x] 教练车牌
#### 有限支持
7 years ago
- [x] 白色警用车牌
- [x] 使馆/港澳车牌
6 years ago
- [x] 双层黄牌
- [x] 武警车牌
#### 待支持
- [ ] 民航车牌
8 years ago
- [ ] 双层武警
- [ ] 双层军牌
8 years ago
- [ ] 双层农用车牌
- [ ] 双层个性化车牌
2 years ago
- [ ] License plates from more countries
8 years ago
2 years ago
###### Note:Due to some imbalanced samples during training, some special license plates have low recognition rates, such as (Embassy/Hong Kong and Macao license plates), which will be improved in the subsequent versions.
8 years ago
2 years ago
### Example
![demo](./images/demo.png)
2 years ago
#### Help
8 years ago
2 years ago
- HyperInspire QQ Group: 529385694
5 years ago