GithubHelp home page GithubHelp logo

szad670401 / hyperlpr Goto Github PK

View Code? Open in Web Editor NEW
5.6K 207.0 2.0K 373.32 MB

基于深度学习高性能中文车牌识别 High Performance Chinese License Plate Recognition Framework.

License: Apache License 2.0

Python 6.89% CMake 0.89% Java 1.94% C++ 88.20% C 1.65% Shell 0.26% Dockerfile 0.03% Objective-C 0.14%
deep-learning plate-recognition android cpp tensorflow

hyperlpr's Introduction

logo_t

HyperLPR3 - High Performance License Plate Recognition Framework.

11

中文文档

Demo APP Installation

Quick Installation

python -m pip install hyperlpr3

support:python3, Windows, Mac, Linux, Raspberry Pi。
720p cpu real-time (st on MBP r15 2.2GHz haswell).

Quick Test

# image url
lpr3 sample -src https://koss.iyong.com/swift/v1/iyong_public/iyong_2596631159095872/image/20190221/1550713902741045679.jpg

# image path
lpr3 sample -src images/test_img.jpg -det high

How to Use

# import opencv
import cv2
# import hyperlpr3
import hyperlpr3 as lpr3

# Instantiate object
catcher = lpr3.LicensePlateCatcher()
# load image
image = cv2.imread("images/test_img.jpg")
# print result
print(catcher(image))

Start the WebAPI service

# start server
lpr3 rest --port 8715 --host 0.0.0.0

Path to open SwaggerUI after startup:http://localhost:8715/api/v1/docs View and test the online Identification API service:

swagger_ui

Q&A

Q:Whether the accuracy of android in the project is consistent with that of apk-demo?

A:Please compile or download the Android shared library from the release and copy it to Prj-Android for testing。

Q:Source of training data for license plates?

A:Since 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 registration dataset。

Q:Provision of training code?

A:The resources provide the old training code, and the training methods for HyperLPR3 will be sorted out and presented later。

Resources

Other Versions

TODO

  • Support for rapid deployment of WebApi services
  • Support multiple license plates and double layers
  • Support large Angle license plate
  • Lightweight recognition model

Specialty

  • 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

Matters Need Attention:

  • 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

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

Cross-platform support

Platform

  • Linux: x86、Armv7、Armv8
  • MacOS: x86
  • Android: arm64-v8a、armeabi-v7a

Embedded Development Board

  • Rockchip: rv1109rv1126(RKNPU)

CPP Dependency

  • Opencv 4.0 above
  • MNN 2.0 above

C/C++ Compiling Dependencies

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 code: eu31

Linux/Mac Shared Library Compilation

  • Need to place or link dependencies in the project root (same level as CMakeLists.txt)
  • We recommend you to compile OpenCV yourself and install it into the system. This can help reduce compilation errors caused by version mismatches and compiler issues with system dependencies. However, you can also try using the pre-compiled OpenCV static library we provide for compilation. To do this, you need to enable the LINUX_USE_3RDPARTY_OPENCV switch.
# execute the script
sh command/build_release_linux_share.sh

Compiled to the build/linux/install/hyperlpr3 dir,Which contains:

  • include - header file
  • lib - shared dir
  • resource - test-images and models dir

Copy the files you need into your project

Linux/Mac Compiling the Demo

  • You need to complete the previous compilation step and ensure it's successful. The compiled files will be located in the root directory: build/linux/install/hyperlpr3. You will need to manually copy them to the current directory.
  • Go to the Prj-Linux folder
# go to Prj-linux
cd Prj-Linux
# exec sh
sh build.sh

The executable program is generated after compilation: PlateRecDemo,and Run the program

# go to build
cd build/
# first param models dir, second param image path
./PlateRecDemo ../hyperlpr3/resource/models/r2_mobile ../hyperlpr3/resource/images/test_img.jpg

Linux/Mac Quick Use SDK Code Example

// Load image
cv::Mat image = cv::imread(image_path);
// Create a ImageData
HLPR_ImageData data = {0};
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);

// Configure license plate recognition parameters
HLPR_ContextConfiguration configuration = {0};
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;
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;
// Instantiating a Context
P_HLPR_Context ctx = HLPR_CreateContext(&configuration);
// Query the Context state
HREESULT ret = HLPR_ContextQueryStatus(ctx);
if (ret != HResultCode::Ok) {
    printf("create error.\n");
    return -1;
}
HLPR_PlateResultList results = {0};
// Execute LPR
HLPR_ContextUpdateStream(ctx, buffer, &results);

for (int i = 0; i < results.plate_size; ++i) {
	// Getting results
    std::string type;
    if (results.plates[i].type == HLPR_PlateType::PLATE_TYPE_UNKNOWN) {
        type =Unknown";
    } else {
        type = TYPES[results.plates[i].type];
    }

    printf("<%d> %s, %s, %f\n", i + 1, type.c_str(),
           results.plates[i].code, results.plates[i].text_confidence);
}

// Release Buffer
HLPR_ReleaseDataBuffer(buffer);
// Release Context
HLPR_ReleaseContext(ctx);

Android: Compile the Shared Library

  • The first step is to install third-party dependencies
  • You need to prepare NDKS and configure environment variables: $ANDROID_NDK
  • Supports cross-compilation on Linux/MacOS
# execute the script
sh command/build_release_android_share.sh

Compiled to the: build/release_android/,Which contains:

  • arm64-v8a - 64bit shard library
  • armeabi-v7a - 32bit shard library

After compiling,Copyarm64-v8aandarmeabi-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-compose,Build Image for hyperlpr_build:

docker build -t hyperlpr_build .

Start compiling the shared library:

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,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:
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  • Step 2. Add the dependency
dependencies {
    implementation 'com.github.HyperInspire:hyperlpr3-android-sdk:1.0.3'
}
  • Step 3. Use hyperlpr in your application
// 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

License Plate Type is Supported(Chinese)

支持

  • 单行蓝牌
  • 单行黄牌
  • 新能源车牌
  • 教练车牌

有限支持

  • 白色警用车牌
  • 使馆/港澳车牌
  • 双层黄牌
  • 武警车牌

待支持

  • 民航车牌
  • 双层武警
  • 双层军牌
  • 双层农用车牌
  • 双层个性化车牌
  • License plates from more countries
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.

Example

demo

Author

Help

  • HyperInspire QQ Group: 529385694

hyperlpr's People

Contributors

alannewimage avatar bjwswang avatar brucexiaok avatar bssnbssn avatar coleflowers avatar da-niao-dan avatar dependabot[bot] avatar dreadlord1984 avatar jinkham avatar jsonshen avatar justid avatar kunliu-kelvin avatar mattzhang1984 avatar szad670401 avatar tunmx avatar yangkezun avatar youngorsu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hyperlpr's Issues

车牌粗定位

车牌粗定位的具体过程是怎样的,感觉博客写的太简洁了看得有点懵

关于车牌检测

请问车牌检测使用的是浅层模型还是基于cascade的cnn模型?
对这个很感兴趣,希望可以共同玩耍哦~

关于检测率与识别率

采用HyperLPR和easypr 相同的测试集(easypr)提供的general_test 文件夹里面的图片测试,发现HyperLPR字符分割和识别率较低,而easyppr 较高似乎与readme说明的不一致,不知道是不是有什么细节参数之类的需要调整呢?

found a bug

In SegmentationFreeRecognizer.cpp line 58, I modified this line, and it worked for me.

if(seq_decode_res.size()>1&&judgeCharRange(seq_decode_res[0].first) && judgeCharRange(seq_decode_res[1].first))

python运行出错

你好,我搭建了你所描述的python运行环境,按照你的python简单调用方法,出现了(no module detect)这个问题,请问是怎么回事?或者我可以直接运行里面的哪个程序可以直接得到结果

测试

如何在数据集上测试正确率?

python版本问题

hi @szad670401 你好
想请问下目前支持的python版本,我的环境是windows
之前用的python2.7,准备python pkg依赖的时候看到以下选项:
Theano(>0.9) or Tensorflow(>1.1.x)
我装了Theano,因为看到这里是or,所以没有装Tensorflow,
装完所有依赖运行代码提示缺乏Tensorflow包
想请问下如果用python2.7,是不是需要额外的配置?

车牌颜色

你好@zeusees 请问,如何获取车牌颜色信息。为什么我采用getPlateType()获取到的车牌颜色信息是错误的。

在flask web应用中报错

当我在flask应用中使用方法时报错,代码如下:

@app.route('/test', methods=['GET'])
def test():
    image = cv2.imread('static/images/006vT0dkzy73eTACbIh15.jpg')
    image, res = pp.SimpleRecognizePlate(image)
    return jsonify(res)

错误信息如下:
error
如果我哪里做错了指点,谢谢

UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)

远程连接到工作站运行代码,原始代码中的输出带有中文,会有“UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
”这个报错,但是我直接在工作站的命令行中运行就不会有这个报错。想知道有没有人遇到过类似的问题?该如何解决(已经尝试了encode/decode,sys等方法都无法解决)?

ValueError

你好,最近正在学习车牌识别的项目,刚好看到您的代码,就下下来试着跑了一下,结果报错了。因为正在学习,不是很懂,想请教一下您。
ValueError: Dimension (-1) must be in the range [0, 2), where 2 is the number of dimensions in the input. for 'metrics/acc/ArgMax' (op: 'ArgMax') with input shapes: [?,?],
2017-10-04 2

关于EasyPR数据集识别率

你好,我想问下作者的:
“识别率高,仅仅针对车牌ROI在EasyPR数据集上,0-error达到 95.2%, 1-error识别率达到 97.4% (指在定位成功后的车牌识别率)”
1、是在EasyPR的600张数据上测试的吗?
2、还有就是0-error是指车牌定位准确率95.2%吗,iou采用多少判定为定位准确呢?

Linux 下编译成功后运行./TRST_PIPLINE出现如下错误 OpenCV Error

OpenCV Error: Unspecified error (FAILED: fs.is_open(). Can't open "model/HorizonalFinemapping.prototxt") in ReadProtoFromTextFile, file /home/firefly/opencv-3.3.0/modules/dnn/src/caffe/caffe_io.cpp, line 1113
terminate called after throwing an instance of 'cv::Exception'
what(): /home/firefly/opencv-3.3.0/modules/dnn/src/caffe/caffe_io.cpp:1113: error: (-2) FAILED: fs.is_open(). Can't open "model/HorizonalFinemapping.prototxt" in function ReadProtoFromTextFile

Aborted (core dumped)

测试样例的精度

我是直接运行python版本的,修改为e2e识别,发现即便使用楼主给的测试样例,精度也无法达到像楼主贴出来的那种精度,想问下楼主是什么原因?

最新端到端的车牌检测

你好,如果我想训练最新的端到端模型,训练数据标签怎么弄的?因为我我看到最后卷积层是len(e2e.chars)+1(84)个输出结果

dataset

你好,我想问下作者的样本量多大才能有比较好的效果(对全国车牌来说)

关于OSError: cannot open resource

运行upload.py报错,如图,百度没有找到答案,请问该怎么解决?

File "D:\Program Files\Anaconda3\envs\tensorflow\lib\site-packages\PIL\ImageFont.py", line 143, in init
self.font = core.getfont(font, size, index, encoding, layout_engine=layout_engine)
OSError: cannot open resource

July0zhu? Checked failed:num_priors_*num_classes_ == bottom[1]->channels()(120015 vs.11430) Number of priors must match number of confidence predictions

Are you July0zhu? I get the link from the July0zhu's recommendation. I am sorry to bother you!but i have some trouble in training of SSD. I found your Issue about ssd‘s training. you said had solved the matter.so I want to ask you how to solve this.please!!! Follow the error:
Checked failed:num_priors_*num_classes_ == bottom[1]->channels()(120015 vs.11430) Number of priors must match number of confidence predictions.
Look forward to your favourable reply!Thanks~
ps: QQ 130588715. can you contact with qq or email as convenient ! thanks again!

添加openCV module后,运行apk直接报错

能否添加一个android导入教程,cmakelists修改过了
E/AndroidRuntime: FATAL EXCEPTION: main Process: pr.platerecognization, PID: 22949 java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/pr.platerecognization-1/base.apk"],nativeLibraryDirectories=[/data/app/pr.platerecognization-1/lib/arm64, /data/app/pr.platerecognization-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "libhyperlpr.so" at java.lang.Runtime.loadLibrary0(Runtime.java:972) at java.lang.System.loadLibrary(System.java:1567) at pr.platerecognization.PlateRecognition.<clinit>(PlateRecognition.java:9) at pr.platerecognization.PlateRecognition.InitPlateRecognizer(Native Method) at pr.platerecognization.MainActivity.initRecognizer(MainActivity.java:139) at pr.platerecognization.MainActivity.onCreate(MainActivity.java:335) at android.app.Activity.performCreate(Activity.java:6912) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2870) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2978) at android.app.ActivityThread.-wrap14(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1628) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6646) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)

请问能否识别同意图片中多辆车的车牌?

您好!
首先非常感谢你们的贡献,这份源码对我的学习有很大的帮助!
我利用python按照说明中进行测试时发现,在文件夹dataset中提供的图片24.jpg中有两辆以上车牌可以进行辨识,但是识别结果只有中间一辆车,请问SimpleRecognizePlate这个方法只能识别一辆车吗?或者还有别的方法可以同时识别的?
最后,我刚下载源码进行测试,对于结果已经非常激动了,还没来得及仔细研究原理,另外在readme中附带的博客地址已经失效,不知是否有更新~~~
以上,致谢!

如何在代码中调节分辨率

我下载了Android示例的apk,通过调节合适的分辨率,可以是别一些模糊的图像。那么在代码中如何调节分辨率?
这个链接"感谢 sundyCoder Android 版本完善"提供的项目不同与可下载的apk,没有调节分辨率选项。

运行新版本出错

运行新版本时报错name 'drawRectBox' is not defined,百度谷歌都查了也不明白是少了什么库,求解答

how to train HyperLPR

hi @szad670401
有什么办法去train HyperLPR吗,最近在使用HyperLPR发现有时候识别率不是很高,想知道是否有办法去train一下HyperLPR,好提高识别率

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.