中文文档
python -m pip install hyperlpr3
# 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
# 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 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:
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。
HyperLPR3车牌识别-五分钟搞定: 中文车牌识别光速部署与使用
HyperLPR3车牌识别-Android-SDK光速部署与使用
HyperLPR3车牌识别-Linux/MacOS使用:C/C++库编译
HyperLPR3车牌识别-Android使用:SDK编译与部署
To be added... Contributions welcome
HyperLPRv1
HyperLPRv2
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
# execute the script
sh command/build_release_linux_share.sh
Compiled to the build/linux/install/hyperlpr3 dir,Which contains:
Copy the files you need into your project
# 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
// 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, %fn", i + 1, type.c_str(),
results.plates[i].code, results.plates[i].text_confidence);
}
// Release Buffer
HLPR_ReleaseDataBuffer(buffer);
// Release Context
HLPR_ReleaseContext(ctx);
# execute the script
sh command/build_release_android_share.sh
Compiled to the: build/release_android/,Which contains:
After compiling,Copyarm64-v8aandarmeabi-v7a dirs to Prj-Android/hyperlpr3/libs,And compile the Prj-Android project to use.
If you need to compile with docker, we provide a few ways to compile:
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
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.
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:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.HyperInspire:hyperlpr3-android-sdk:1.0.3'
}
// 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