中文文档
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
启动后打开SwaggerUI的路径:http://localhost:8715/api/v1/docs 查看并测试在线识别API服务:
Q:项目中android的准确率与apk-demo的准确率是否一致?
A:请从release中编译或下载Android共享库,并将其复制到Prj-Android进行测试。
Q:车牌训练数据来源?
A:由于用于训练的车牌数据涉及法律隐私等问题,本项目无法提供。开放更多大数据集CCPD注册数据集。
Q:提供培训代码吗?
A:资源提供了旧的训练代码,HyperLPR3的训练方法稍后会整理并呈现。
HyperLPR3车牌识别-五分钟搞定:中文车牌识别光速配置与使用
HyperLPR3车牌识别-Android-SDK光速部署与使用
HyperLPR3车牌识别-Linux/MacOS使用:C/C++库编译
HyperLPR3车牌识别-Android使用:SDK编译与部署
待补充...欢迎投稿
超级LPRv1
超级LPRv2
编译C/C++项目需要使用第三方依赖库。下载库后解压,通过复制或软链接放入根目录(与CMakeLists.txt同级)。baidu驱动码:eu31
# execute the script
sh command/build_release_linux_share.sh
编译到build/linux/install/hyperlpr3目录,其中包含:
将需要的文件复制到项目中
# go to Prj-linux
cd Prj-Linux
# exec sh
sh build.sh
编译后生成可执行程序: PlateRecDemo ,并运行程序
# 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
编译到: build/release_android/ ,其中包含:
编译完成后,将arm64-v8a和armeabi-v7a目录复制到Prj-Android/hyperlpr3/libs ,并编译Prj-Android工程使用。
如果您需要使用docker编译,我们提供了几种编译方式:
您需要安装 docker 和 docker-compose,为hyperlpr_build构建镜像:
docker build -t hyperlpr_build .
开始编译共享库:
docker-compose up build_linux_x86_shared_lib
构建目录: build/linux
我们在Android SDK源码中提供了一个演示项目:hyperlpr3-android-sdk,您可以根据需要编译共享库并使用该项目。
如果您需要将我们的sdk快速集成到您自己的Android项目中,那么您可以在项目的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 );
了解更多: Prj-Android