中文文檔
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同級)。
# 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