README
This commit is contained in:
+9
-3
@@ -41,7 +41,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/cpp/platform)
|
|||||||
# must use mnn
|
# must use mnn
|
||||||
add_definitions("-DINFERENCE_HELPER_ENABLE_MNN")
|
add_definitions("-DINFERENCE_HELPER_ENABLE_MNN")
|
||||||
|
|
||||||
set(LINK_THIRD_LIBS pthread MNN)
|
set(LINK_THIRD_LIBS pthread MNN m)
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ")
|
||||||
@@ -85,8 +85,8 @@ else ()
|
|||||||
set(PLAT linux)
|
set(PLAT linux)
|
||||||
endif ()
|
endif ()
|
||||||
# MNN Third party dependence
|
# MNN Third party dependence
|
||||||
set(MNN_INCLUDE_DIRS ${PATH_3RDPARTY}/MNN-2.2.0/${PLAT}-static/include)
|
set(MNN_INCLUDE_DIRS ${PATH_3RDPARTY}/MNN-2.2.0/${PLAT}/include)
|
||||||
set(MNN_LIBS ${PATH_3RDPARTY}/MNN-2.2.0/${PLAT}-static/lib)
|
set(MNN_LIBS ${PATH_3RDPARTY}/MNN-2.2.0/${PLAT}/lib)
|
||||||
# OpenCV Third party dependence
|
# OpenCV Third party dependence
|
||||||
set(OpenCV_DIR ${PATH_3RDPARTY}/opencv-4.5.1/${PLAT}/lib/cmake/opencv4)
|
set(OpenCV_DIR ${PATH_3RDPARTY}/opencv-4.5.1/${PLAT}/lib/cmake/opencv4)
|
||||||
set(OpenCV_STATIC_INCLUDE_DIR ${PATH_3RDPARTY}/opencv-4.5.1/${PLAT}/include/opencv4)
|
set(OpenCV_STATIC_INCLUDE_DIR ${PATH_3RDPARTY}/opencv-4.5.1/${PLAT}/include/opencv4)
|
||||||
@@ -147,6 +147,12 @@ endif()
|
|||||||
set(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR}/install/hyperlpr3)
|
set(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR}/install/hyperlpr3)
|
||||||
message(CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX})
|
message(CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX})
|
||||||
install(DIRECTORY resource DESTINATION ./)
|
install(DIRECTORY resource DESTINATION ./)
|
||||||
|
if (APPLE)
|
||||||
|
install(FILES ${MNN_LIBS}/libMNN.dylib DESTINATION ./lib)
|
||||||
|
else()
|
||||||
|
install(FILES ${MNN_LIBS}/libMNN.so DESTINATION ./lib)
|
||||||
|
endif ()
|
||||||
|
|
||||||
if (BUILD_SAMPLES)
|
if (BUILD_SAMPLES)
|
||||||
install(TARGETS ContextSample DESTINATION ./bin)
|
install(TARGETS ContextSample DESTINATION ./bin)
|
||||||
install(TARGETS CAPISample DESTINATION ./bin)
|
install(TARGETS CAPISample DESTINATION ./bin)
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdk 28
|
compileSdk 31
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.hyperai.hyperlpr_sdk_demo"
|
applicationId "com.hyperai.example.lpr3_demo"
|
||||||
minSdk 22
|
minSdk 21
|
||||||
targetSdk 28
|
targetSdk 31
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
|
||||||
@@ -29,17 +29,17 @@ android {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
|
// Tools
|
||||||
implementation 'org.greenrobot:eventbus:3.0.0'
|
implementation 'org.greenrobot:eventbus:3.0.0'
|
||||||
implementation 'com.android.support:appcompat-v7:28.0.0'
|
implementation 'com.github.smuyyh:ImageSelector:3.0'
|
||||||
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
|
implementation 'com.github.bumptech.glide:glide:3.7.0'
|
||||||
|
// HyperLPR3 sdk
|
||||||
|
implementation 'com.github.HyperInspire:hyperlpr3-android-sdk:1.0.2'
|
||||||
|
|
||||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||||
implementation 'com.google.android.material:material:1.3.0'
|
implementation 'com.google.android.material:material:1.3.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
implementation project(path: ':hyperlpr3')
|
|
||||||
testImplementation 'junit:junit:4.+'
|
testImplementation 'junit:junit:4.+'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||||
implementation 'com.github.smuyyh:ImageSelector:3.0'
|
|
||||||
implementation 'com.github.bumptech.glide:glide:3.7.0'
|
|
||||||
}
|
}
|
||||||
Binary file not shown.
@@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"version": 3,
|
|
||||||
"artifactType": {
|
|
||||||
"type": "APK",
|
|
||||||
"kind": "Directory"
|
|
||||||
},
|
|
||||||
"applicationId": "com.hyperai.hyperlpr_sdk_demo",
|
|
||||||
"variantName": "release",
|
|
||||||
"elements": [
|
|
||||||
{
|
|
||||||
"type": "SINGLE",
|
|
||||||
"filters": [],
|
|
||||||
"attributes": [],
|
|
||||||
"versionCode": 1,
|
|
||||||
"versionName": "1.0",
|
|
||||||
"outputFile": "app-release.apk"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"elementType": "File"
|
|
||||||
}
|
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
package com.hyperai.hyperlpr_sdk_demo;
|
package com.hyperai.example.lpr3_demo;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
@@ -21,6 +21,6 @@ public class ExampleInstrumentedTest {
|
|||||||
public void useAppContext() {
|
public void useAppContext() {
|
||||||
// Context of the app under test.
|
// Context of the app under test.
|
||||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||||
assertEquals("com.hyperai.hyperlpr_sdk_demo", appContext.getPackageName());
|
assertEquals("com.hyperai.example.lpr3_demo", appContext.getPackageName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="com.hyperai.hyperlpr_sdk_demo">
|
package="com.hyperai.example.lpr3_demo">
|
||||||
|
|
||||||
<uses-feature android:name="android.hardware.camera" />
|
<uses-feature android:name="android.hardware.camera" />
|
||||||
<uses-feature android:name="android.hardware.camera.autofocus" />
|
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.HyperLPR_SDK_Demo">
|
android:theme="@style/Theme.HyperLPR3Example">
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
@@ -49,11 +49,6 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".CameraActivity" />
|
<activity android:name=".CameraActivity" />
|
||||||
<!-- <activity-->
|
|
||||||
<!-- android:name=".CameraPlate"-->
|
|
||||||
<!-- android:screenOrientation="landscape"-->
|
|
||||||
<!-- >-->
|
|
||||||
<!-- </activity>-->
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
+2
-11
@@ -1,18 +1,14 @@
|
|||||||
package com.hyperai.hyperlpr_sdk_demo;
|
package com.hyperai.example.lpr3_demo;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
|
||||||
import com.hyperai.hyperlpr3.HyperLPR3;
|
import com.hyperai.hyperlpr3.HyperLPR3;
|
||||||
import com.hyperai.hyperlpr3.bean.Plate;
|
import com.hyperai.hyperlpr3.bean.Plate;
|
||||||
|
|
||||||
@@ -20,9 +16,6 @@ import org.greenrobot.eventbus.EventBus;
|
|||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
import org.greenrobot.eventbus.ThreadMode;
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author by hs-johnny
|
* @author by hs-johnny
|
||||||
@@ -33,7 +26,6 @@ public class CameraActivity extends Activity {
|
|||||||
FrameLayout previewFl;
|
FrameLayout previewFl;
|
||||||
CameraPreviews cameraPreview;
|
CameraPreviews cameraPreview;
|
||||||
TextView plateTv;
|
TextView plateTv;
|
||||||
// TextView regTv;
|
|
||||||
ImageView image;
|
ImageView image;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -98,7 +90,6 @@ public class CameraActivity extends Activity {
|
|||||||
plateTv.setText(showText);
|
plateTv.setText(showText);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// stopPreview();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+4
-11
@@ -1,11 +1,10 @@
|
|||||||
package com.hyperai.hyperlpr_sdk_demo;
|
package com.hyperai.example.lpr3_demo;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.hardware.Camera;
|
import android.hardware.Camera;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
//import android.support.v4.content.ContextCompat;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
@@ -14,16 +13,15 @@ import android.view.SurfaceHolder;
|
|||||||
import android.view.SurfaceView;
|
import android.view.SurfaceView;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
|
import com.hyperai.hyperlpr3.HyperLPR3;
|
||||||
|
import com.hyperai.hyperlpr3.bean.HyperLPRParameter;
|
||||||
|
import com.hyperai.hyperlpr3.bean.Plate;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.hyperai.hyperlpr3.HyperLPR3;
|
|
||||||
import com.hyperai.hyperlpr3.bean.HyperLPRParameter;
|
|
||||||
import com.hyperai.hyperlpr3.bean.Plate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author by hs-johnny
|
* @author by hs-johnny
|
||||||
* Created on 2019/6/17
|
* Created on 2019/6/17
|
||||||
@@ -50,11 +48,7 @@ public class CameraPreviews extends SurfaceView implements SurfaceHolder.Callbac
|
|||||||
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||||
mPaint.setStrokeWidth(2);
|
mPaint.setStrokeWidth(2);
|
||||||
mPaint.setStyle(Paint.Style.STROKE);
|
mPaint.setStyle(Paint.Style.STROKE);
|
||||||
// mPaint.setColor(ContextCompat.getColor(context, R.color.colorAccent));
|
|
||||||
|
|
||||||
HyperLPRParameter parameter = new HyperLPRParameter();
|
|
||||||
// hyperLPR3 = new HyperLPR3();
|
|
||||||
// hyperLPR3.init(mContext, parameter);
|
|
||||||
}
|
}
|
||||||
public Camera getCameraInstance(){
|
public Camera getCameraInstance(){
|
||||||
if (mCamera == null){
|
if (mCamera == null){
|
||||||
@@ -137,7 +131,6 @@ public class CameraPreviews extends SurfaceView implements SurfaceHolder.Callbac
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!isStopReg && plates.length > 0) {
|
if(!isStopReg && plates.length > 0) {
|
||||||
// isStopReg = true;
|
|
||||||
sendPlate(plates);
|
sendPlate(plates);
|
||||||
}
|
}
|
||||||
|
|
||||||
+2
-3
@@ -1,4 +1,4 @@
|
|||||||
package com.hyperai.hyperlpr_sdk_demo;
|
package com.hyperai.example.lpr3_demo;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
@@ -27,7 +27,6 @@ import com.yuyh.library.imgsel.config.ISListConfig;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private Button cameraBtn;
|
private Button cameraBtn;
|
||||||
@@ -78,7 +77,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
verifyStoragePermissions(this);
|
verifyStoragePermissions(this);
|
||||||
|
|
||||||
|
|
||||||
// 车牌识别算法配置参数
|
// 车牌识别算法配置参数
|
||||||
HyperLPRParameter parameter = new HyperLPRParameter()
|
HyperLPRParameter parameter = new HyperLPRParameter()
|
||||||
.setDetLevel(HyperLPR3.DETECT_LEVEL_LOW)
|
.setDetLevel(HyperLPR3.DETECT_LEVEL_LOW)
|
||||||
@@ -161,6 +159,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
if (bitmap != null) {
|
if (bitmap != null) {
|
||||||
|
|
||||||
imageView.setImageBitmap(bitmap);
|
imageView.setImageBitmap(bitmap);
|
||||||
|
// 调用车牌识别
|
||||||
Plate[] plates = HyperLPR3.getInstance().plateRecognition(bitmap, HyperLPR3.CAMERA_ROTATION_0, HyperLPR3.STREAM_BGRA);
|
Plate[] plates = HyperLPR3.getInstance().plateRecognition(bitmap, HyperLPR3.CAMERA_ROTATION_0, HyperLPR3.STREAM_BGRA);
|
||||||
for (Plate plate: plates) {
|
for (Plate plate: plates) {
|
||||||
String type = "未知车牌";
|
String type = "未知车牌";
|
||||||
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
@@ -1,3 +1,3 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">HyperLPR3-App</string>
|
<string name="app_name">HyperLPR3-Example</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="Theme.HyperLPR_SDK_Demo" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
<style name="Theme.HyperLPR3Example" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||||
<!-- Primary brand color. -->
|
<!-- Primary brand color. -->
|
||||||
<item name="colorPrimary">@color/purple_500</item>
|
<item name="colorPrimary">@color/purple_500</item>
|
||||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.hyperai.hyperlpr3;
|
package com.hyperai.example.lpr3_demo;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package com.hyperai.hyperlpr_sdk_demo;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Example local unit test, which will execute on the development machine (host).
|
|
||||||
*
|
|
||||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
|
||||||
*/
|
|
||||||
public class ExampleUnitTest {
|
|
||||||
@Test
|
|
||||||
public void addition_isCorrect() {
|
|
||||||
assertEquals(4, 2 + 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,7 @@ buildscript {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath "com.android.tools.build:gradle:7.0.2"
|
classpath "com.android.tools.build:gradle:7.0.3"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
#Fri Jan 27 02:05:45 CST 2023
|
#Tue Mar 07 11:14:11 CST 2023
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
/build
|
|
||||||
-21
@@ -1,21 +0,0 @@
|
|||||||
# Add project specific ProGuard rules here.
|
|
||||||
# You can control the set of applied configuration files using the
|
|
||||||
# proguardFiles setting in build.gradle.
|
|
||||||
#
|
|
||||||
# For more details, see
|
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
|
||||||
# class:
|
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
||||||
# public *;
|
|
||||||
#}
|
|
||||||
|
|
||||||
# Uncomment this to preserve the line number information for
|
|
||||||
# debugging stack traces.
|
|
||||||
#-keepattributes SourceFile,LineNumberTable
|
|
||||||
|
|
||||||
# If you keep the line number information, uncomment this to
|
|
||||||
# hide the original source file name.
|
|
||||||
#-renamesourcefileattribute SourceFile
|
|
||||||
-26
@@ -1,26 +0,0 @@
|
|||||||
package com.hyperai.hyperlpr3;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.test.platform.app.InstrumentationRegistry;
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instrumented test, which will execute on an Android device.
|
|
||||||
*
|
|
||||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
|
||||||
*/
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class ExampleInstrumentedTest {
|
|
||||||
@Test
|
|
||||||
public void useAppContext() {
|
|
||||||
// Context of the app under test.
|
|
||||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
|
||||||
assertEquals("com.hyperai.hyperlpr3.test", appContext.getPackageName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
package="com.hyperai.hyperlpr3">
|
|
||||||
|
|
||||||
</manifest>
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,108 +0,0 @@
|
|||||||
package com.hyperai.hyperlpr3;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.hyperai.hyperlpr3.api.APIDefine;
|
|
||||||
import com.hyperai.hyperlpr3.bean.HyperLPRParameter;
|
|
||||||
import com.hyperai.hyperlpr3.bean.Plate;
|
|
||||||
import com.hyperai.hyperlpr3.core.HyperLPRCore;
|
|
||||||
import com.hyperai.hyperlpr3.settings.TypeDefine;
|
|
||||||
import com.hyperai.hyperlpr3.settings.SDKConfig;
|
|
||||||
import com.hyperai.hyperlpr3.utils.SDKUtils;
|
|
||||||
|
|
||||||
public class HyperLPR3 extends TypeDefine implements APIDefine {
|
|
||||||
|
|
||||||
private final String TAG = "HyperLPR3-SDK";
|
|
||||||
|
|
||||||
private final HyperLPRCore mCore;
|
|
||||||
|
|
||||||
private boolean isInitSuccess;
|
|
||||||
|
|
||||||
private HyperLPR3() {
|
|
||||||
mCore = new HyperLPRCore();
|
|
||||||
isInitSuccess = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class LazyHolder {
|
|
||||||
private static final HyperLPR3 INSTANCE = new HyperLPR3();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final HyperLPR3 getInstance() {
|
|
||||||
return LazyHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void release() {
|
|
||||||
mCore.release();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void finalize() throws Throwable {
|
|
||||||
super.finalize();
|
|
||||||
release();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize the license plate recognition algorithm SDK
|
|
||||||
*
|
|
||||||
* @param context context
|
|
||||||
* @param parameter Initialization parameter
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void init(Context context, HyperLPRParameter parameter) {
|
|
||||||
if (!isInitSuccess) {
|
|
||||||
String mResourceFolderPath = context.getExternalFilesDir(null).getAbsolutePath() + "/";
|
|
||||||
SDKUtils.copyFilesFromAssets(context, SDKConfig.packDirName, mResourceFolderPath);
|
|
||||||
Log.i(TAG, "resource: " + mResourceFolderPath);
|
|
||||||
if (parameter.getModelPath() == null || "".equals(parameter.getModelPath())) {
|
|
||||||
parameter.setModelPath(mResourceFolderPath);
|
|
||||||
}
|
|
||||||
mCore.createRecognizerContext(parameter);
|
|
||||||
isInitSuccess = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* License plate recognition interface.
|
|
||||||
*
|
|
||||||
* @param buf Image data buffer.
|
|
||||||
* @param height Height of the image
|
|
||||||
* @param width Width of the image
|
|
||||||
* @param rotation Original data buffer rotation Angle
|
|
||||||
* @param format Buffer data coded format
|
|
||||||
* @return Resulting object array
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Plate[] plateRecognition(byte[] buf, int height, int width, int rotation, int format) {
|
|
||||||
if (!isInitSuccess) {
|
|
||||||
Log.e(TAG, "HyperLPR3 is uninitialized.");
|
|
||||||
return new Plate[0];
|
|
||||||
}
|
|
||||||
return mCore.plateRecognitionFromBuffer(buf, height, width, rotation, format);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* License plate recognition interface.
|
|
||||||
*
|
|
||||||
* @param image Bitmap image
|
|
||||||
* @param rotation Original data buffer rotation Angle
|
|
||||||
* @param format Buffer data coded format
|
|
||||||
* @return Resulting object array
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Plate[] plateRecognition(Bitmap image, int rotation, int format) {
|
|
||||||
if (!isInitSuccess) {
|
|
||||||
Log.e(TAG, "HyperLPR3 is uninitialized.");
|
|
||||||
return new Plate[0];
|
|
||||||
}
|
|
||||||
int mWidth = image.getWidth();
|
|
||||||
int mHeight = image.getHeight();
|
|
||||||
int[] data = new int[image.getWidth() * image.getHeight()];
|
|
||||||
image.getPixels(data, 0, mWidth, 0, 0, mWidth, mHeight);
|
|
||||||
return mCore.plateRecognitionFromImage(data, mHeight, mWidth, rotation, format);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package com.hyperai.hyperlpr3.api;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
|
|
||||||
import com.hyperai.hyperlpr3.bean.HyperLPRParameter;
|
|
||||||
import com.hyperai.hyperlpr3.bean.Plate;
|
|
||||||
|
|
||||||
public interface APIDefine {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize the license plate recognition algorithm SDK
|
|
||||||
*
|
|
||||||
* @param context context
|
|
||||||
* @param parameter Initialization parameter
|
|
||||||
* */
|
|
||||||
void init(Context context, HyperLPRParameter parameter);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* License plate recognition interface.
|
|
||||||
*
|
|
||||||
* @param buf Image data buffer.
|
|
||||||
* @param height Height of the image
|
|
||||||
* @param width Width of the image
|
|
||||||
* @param rotation Original data buffer rotation Angle
|
|
||||||
* @param format Buffer data coded format
|
|
||||||
* @return Resulting object array
|
|
||||||
*/
|
|
||||||
Plate[] plateRecognition(byte[] buf, int height, int width, int rotation, int format);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* License plate recognition interface.
|
|
||||||
*
|
|
||||||
* @param image Bitmap image
|
|
||||||
* @param rotation Original data buffer rotation Angle
|
|
||||||
* @param format Buffer data coded format
|
|
||||||
* @return Resulting object array
|
|
||||||
*/
|
|
||||||
Plate[] plateRecognition(Bitmap image, int rotation, int format);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
package com.hyperai.hyperlpr3.bean;
|
|
||||||
|
|
||||||
import com.hyperai.hyperlpr3.settings.TypeDefine;
|
|
||||||
|
|
||||||
public class HyperLPRParameter {
|
|
||||||
|
|
||||||
private String modelPath;
|
|
||||||
|
|
||||||
private int threads = 1;
|
|
||||||
|
|
||||||
private boolean useHalf = true;
|
|
||||||
|
|
||||||
private float boxConfThreshold = 0.25f;
|
|
||||||
|
|
||||||
private float nmsThreshold = 0.6f;
|
|
||||||
|
|
||||||
private float recConfidenceThreshold = 0.85f;
|
|
||||||
|
|
||||||
private int detLevel = TypeDefine.DETECT_LEVEL_LOW;
|
|
||||||
|
|
||||||
private int maxNum = 3;
|
|
||||||
|
|
||||||
public HyperLPRParameter() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxNum() {
|
|
||||||
return maxNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HyperLPRParameter setMaxNum(int maxNum) {
|
|
||||||
this.maxNum = maxNum;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getModelPath() {
|
|
||||||
return modelPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HyperLPRParameter setModelPath(String modelPath) {
|
|
||||||
this.modelPath = modelPath;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getThreads() {
|
|
||||||
return threads;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HyperLPRParameter setThreads(int threads) {
|
|
||||||
this.threads = threads;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isUseHalf() {
|
|
||||||
return useHalf;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HyperLPRParameter setUseHalf(boolean useHalf) {
|
|
||||||
this.useHalf = useHalf;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getBoxConfThreshold() {
|
|
||||||
return boxConfThreshold;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HyperLPRParameter setBoxConfThreshold(float boxConfThreshold) {
|
|
||||||
this.boxConfThreshold = boxConfThreshold;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getNmsThreshold() {
|
|
||||||
return nmsThreshold;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HyperLPRParameter setNmsThreshold(float nmsThreshold) {
|
|
||||||
this.nmsThreshold = nmsThreshold;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getRecConfidenceThreshold() {
|
|
||||||
return recConfidenceThreshold;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HyperLPRParameter setRecConfidenceThreshold(float recConfidenceThreshold) {
|
|
||||||
this.recConfidenceThreshold = recConfidenceThreshold;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getDetLevel() {
|
|
||||||
return detLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HyperLPRParameter setDetLevel(int detLevel) {
|
|
||||||
this.detLevel = detLevel;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
package com.hyperai.hyperlpr3.bean;
|
|
||||||
|
|
||||||
public class Plate {
|
|
||||||
|
|
||||||
private float x1;
|
|
||||||
|
|
||||||
private float y1;
|
|
||||||
|
|
||||||
private float x2;
|
|
||||||
|
|
||||||
private float y2;
|
|
||||||
|
|
||||||
private int type;
|
|
||||||
|
|
||||||
private float confidence;
|
|
||||||
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
public Plate() {};
|
|
||||||
|
|
||||||
public float getX1() {
|
|
||||||
return x1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setX1(float x1) {
|
|
||||||
this.x1 = x1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getY1() {
|
|
||||||
return y1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setY1(float y1) {
|
|
||||||
this.y1 = y1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getX2() {
|
|
||||||
return x2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setX2(float x2) {
|
|
||||||
this.x2 = x2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getY2() {
|
|
||||||
return y2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setY2(float y2) {
|
|
||||||
this.y2 = y2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(int type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getConfidence() {
|
|
||||||
return confidence;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConfidence(float confidence) {
|
|
||||||
this.confidence = confidence;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCode(String code) {
|
|
||||||
this.code = code;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Plate{" +
|
|
||||||
"x1=" + x1 +
|
|
||||||
", y1=" + y1 +
|
|
||||||
", x2=" + x2 +
|
|
||||||
", y2=" + y2 +
|
|
||||||
", type=" + type +
|
|
||||||
", confidence=" + confidence +
|
|
||||||
", code='" + code + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
package com.hyperai.hyperlpr3.core;
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.hyperai.hyperlpr3.bean.HyperLPRParameter;
|
|
||||||
import com.hyperai.hyperlpr3.bean.Plate;
|
|
||||||
|
|
||||||
public class HyperLPRCore {
|
|
||||||
|
|
||||||
final String TAG = "HyperLPRCore";
|
|
||||||
|
|
||||||
static {
|
|
||||||
System.loadLibrary("hyperlpr3");
|
|
||||||
}
|
|
||||||
|
|
||||||
private long ctxHandle_;
|
|
||||||
|
|
||||||
private boolean isRunning_;
|
|
||||||
|
|
||||||
public void createRecognizerContext(HyperLPRParameter parameter) {
|
|
||||||
ctxHandle_ = CreateRecognizerContext(parameter);
|
|
||||||
Log.i(TAG, "HANDLE: " + ctxHandle_);
|
|
||||||
isRunning_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Plate[] plateRecognitionFromBuffer(byte[] buf, int height, int width, int rotation, int format) {
|
|
||||||
return PlateRecognitionFromBuffer(ctxHandle_, buf, height, width, rotation, format);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Plate[] plateRecognitionFromImage(int[] buf, int height, int width, int rotation, int format) {
|
|
||||||
return PlateRecognitionFromImage(ctxHandle_, buf, height, width, rotation, format);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int release() {
|
|
||||||
int ret = -1;
|
|
||||||
if (isRunning_) {
|
|
||||||
ret = ReleaseRecognizerContext(ctxHandle_);
|
|
||||||
isRunning_ = false;
|
|
||||||
ctxHandle_ = 0;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===================Native==================
|
|
||||||
|
|
||||||
// native void TestBuffer(String savePath, byte[] buf, int height, int width, int rotation);
|
|
||||||
|
|
||||||
native long CreateRecognizerContext(HyperLPRParameter parameterObj);
|
|
||||||
|
|
||||||
native int ReleaseRecognizerContext(long handle);
|
|
||||||
|
|
||||||
native Plate[] PlateRecognitionFromBuffer(long handle, byte[] buf, int height, int width, int rotation, int format);
|
|
||||||
|
|
||||||
native Plate[] PlateRecognitionFromImage(long handle, int[] buf, int height, int width, int rotation, int format);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package com.hyperai.hyperlpr3.settings;
|
|
||||||
|
|
||||||
public class SDKConfig {
|
|
||||||
|
|
||||||
public static final String packDirName = "r2_mobile";
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package com.hyperai.hyperlpr3.settings;
|
|
||||||
|
|
||||||
public class TypeDefine {
|
|
||||||
|
|
||||||
/** 四种情况的转角 */
|
|
||||||
public static final int CAMERA_ROTATION_0 = 0;
|
|
||||||
public static final int CAMERA_ROTATION_90 = 1;
|
|
||||||
public static final int CAMERA_ROTATION_180 = 2;
|
|
||||||
public static final int CAMERA_ROTATION_270 = 3;
|
|
||||||
|
|
||||||
/** 低开销检测模式 */
|
|
||||||
public static final int DETECT_LEVEL_LOW = 0;
|
|
||||||
/** 高开销检测模式 */
|
|
||||||
public static final int DETECT_LEVEL_HIGH = 1;
|
|
||||||
|
|
||||||
/** Image in RGB format - RGB排列格式的图像 */
|
|
||||||
public static final int STREAM_RGB = 0;
|
|
||||||
/** Image in BGR format (Opencv Mat default) - BGR排列格式的图像(OpenCV的Mat默认) */
|
|
||||||
public static final int STREAM_BGR = 1;
|
|
||||||
/** Image in RGB with alpha channel format -带alpha通道的RGB排列格式的图像 */
|
|
||||||
public static final int STREAM_RGBA = 2;
|
|
||||||
/** Image in BGR with alpha channel format -带alpha通道的BGR排列格式的图像 */
|
|
||||||
public static final int STREAM_BGRA = 3;
|
|
||||||
/** Image in YUV NV12 format - YUV NV12排列的图像格式 */
|
|
||||||
public static final int STREAM_YUV_NV12 = 4;
|
|
||||||
/** Image in YUV NV21 format - YUV NV21排列的图像格式 */
|
|
||||||
public static final int STREAM_YUV_NV21 = 5;
|
|
||||||
|
|
||||||
|
|
||||||
/** 未知车牌 */
|
|
||||||
public static final int PLATE_TYPE_UNKNOWN = -1;
|
|
||||||
/** 蓝牌 */
|
|
||||||
public static final int PLATE_TYPE_BLUE = 0;
|
|
||||||
/** 黄牌单层 */
|
|
||||||
public static final int PLATE_TYPE_YELLOW_SINGLE = 1;
|
|
||||||
/** 白牌单层 */
|
|
||||||
public static final int PLATE_TYPE_WHILE_SINGLE = 2;
|
|
||||||
/** 绿牌新能源 */
|
|
||||||
public static final int PLATE_TYPE_GREEN = 3;
|
|
||||||
/** 黑牌港澳 */
|
|
||||||
public static final int PLATE_TYPE_BLACK_HK_MACAO = 4;
|
|
||||||
/** 香港单层 */
|
|
||||||
public static final int PLATE_TYPE_HK_SINGLE = 5;
|
|
||||||
/** 香港双层 */
|
|
||||||
public static final int PLATE_TYPE_HK_DOUBLE = 6;
|
|
||||||
/** 澳门单层 */
|
|
||||||
public static final int PLATE_TYPE_MACAO_SINGLE = 7;
|
|
||||||
/** 澳门双层 */
|
|
||||||
public static final int PLATE_TYPE_MACAO_DOUBLE = 8;
|
|
||||||
/** 黄牌双层 */
|
|
||||||
public static final int PLATE_TYPE_YELLOW_DOUBLE = 9;
|
|
||||||
|
|
||||||
public static final String[] PLATE_TYPE_MAPS = {"蓝牌", "黄牌单层", "白牌单层", "绿牌新能源", "黑牌港澳", "香港单层", "香港双层", "澳门单层", "澳门双层", "黄牌双层"};
|
|
||||||
}
|
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
package com.hyperai.hyperlpr3.utils;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.res.AssetManager;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.DashPathEffect;
|
|
||||||
import android.graphics.Matrix;
|
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.graphics.Path;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
public class SDKUtils {
|
|
||||||
static public void copyFilesFromAssets(Context context, String oldPath, String newPath) {
|
|
||||||
try {
|
|
||||||
String[] fileNames = context.getAssets().list(oldPath);
|
|
||||||
if (fileNames.length > 0) {
|
|
||||||
// directory
|
|
||||||
File file = new File(newPath);
|
|
||||||
if (!file.mkdir()) {
|
|
||||||
Log.d("mkdir", "can't make folder");
|
|
||||||
}
|
|
||||||
// return false; // copy recursively
|
|
||||||
for (String fileName : fileNames) {
|
|
||||||
copyFilesFromAssets(context, oldPath + "/" + fileName,
|
|
||||||
newPath + "/" + fileName);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// file
|
|
||||||
InputStream is = context.getAssets().open(oldPath);
|
|
||||||
FileOutputStream fos = new FileOutputStream(new File(newPath));
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
int byteCount;
|
|
||||||
while ((byteCount = is.read(buffer)) != -1) {
|
|
||||||
fos.write(buffer, 0, byteCount);
|
|
||||||
}
|
|
||||||
fos.flush();
|
|
||||||
is.close();
|
|
||||||
fos.close();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static public void mkdirsFeaturesAssets(Context context, String path, String images, String features) {
|
|
||||||
try {
|
|
||||||
File file = new File(path);
|
|
||||||
File imagePath = new File(path + images);
|
|
||||||
File featurePath = new File(path + features);
|
|
||||||
if (!file.mkdir()) {
|
|
||||||
Log.d("mkdir", "can't make folder: " + file);
|
|
||||||
}
|
|
||||||
if (!imagePath.mkdir()) {
|
|
||||||
Log.d("mkdir", "can't make folder: " + imagePath);
|
|
||||||
}
|
|
||||||
if (!featurePath.mkdir()) {
|
|
||||||
Log.d("mkdir", "can't make folder: " + featurePath);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static public String saveBitmap(String savePath, String name, Bitmap bitmap) throws IOException {
|
|
||||||
File f = new File(savePath, name + ".png");
|
|
||||||
if (f.exists()) {
|
|
||||||
f.delete();
|
|
||||||
}
|
|
||||||
FileOutputStream out = new FileOutputStream(f);
|
|
||||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
|
|
||||||
out.flush();
|
|
||||||
out.close();
|
|
||||||
return f.getAbsolutePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static public boolean cropperBitmap(Bitmap bitmap, int[] rePoints, String sdcardPath, String name) {
|
|
||||||
int newWidth = 160;
|
|
||||||
int newHeight = 192;
|
|
||||||
float scaleWidth = ((float) newWidth) / bitmap.getWidth();
|
|
||||||
float scaleHeight = ((float) newHeight) / bitmap.getHeight();
|
|
||||||
Matrix matrix = new Matrix();
|
|
||||||
// matrix.postTranslate()
|
|
||||||
matrix.postScale(scaleWidth, scaleHeight);
|
|
||||||
matrix.setScale(-1, 1);
|
|
||||||
int px = Math.max(0, rePoints[0]);
|
|
||||||
int py = Math.max(0, rePoints[1]);
|
|
||||||
int w = rePoints[2] - px;
|
|
||||||
int h = rePoints[3] - py;
|
|
||||||
int pw = (bitmap.getWidth() - w > 0) ? w - 1 : bitmap.getWidth() - 1;
|
|
||||||
int ph = (bitmap.getHeight() - h > 0) ? h - 1 : bitmap.getHeight() - 1;
|
|
||||||
try {
|
|
||||||
Bitmap crop = Bitmap.createBitmap(bitmap, px, py, pw, ph, matrix, true);
|
|
||||||
// String sdcardPath = Environment.getExternalStorageDirectory() + File.separator + Const.root + Const.save + Const.images;
|
|
||||||
saveBitmap(sdcardPath, name, crop);
|
|
||||||
} catch (Exception err) {
|
|
||||||
Log.d("crop", "ext");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static Bitmap getImageFromAssetsFile(Context context, String fileName) {
|
|
||||||
Bitmap image = null;
|
|
||||||
AssetManager am = context.getResources().getAssets();
|
|
||||||
try {
|
|
||||||
InputStream is = am.open(fileName);
|
|
||||||
image = BitmapFactory.decodeStream(is);
|
|
||||||
is.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -4,9 +4,8 @@ dependencyResolutionManagement {
|
|||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
jcenter() // Warning: this repository is going to shut down soon
|
jcenter() // Warning: this repository is going to shut down soon
|
||||||
maven { url "https://jitpack.io" }
|
maven { url 'https://jitpack.io' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rootProject.name = "HyperLPR_SDK_Demo"
|
rootProject.name = "HyperLPR3-Example"
|
||||||
include ':app'
|
include ':app'
|
||||||
include ':hyperlpr3'
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.10.2)
|
|||||||
project(HyperLPR3-LinuxDemo)
|
project(HyperLPR3-LinuxDemo)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
set(PLAT darwin)
|
set(PLAT darwin)
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
mkdir "build"
|
||||||
|
cd "build"
|
||||||
|
|
||||||
|
cmake ..
|
||||||
|
make -j
|
||||||
|
|
||||||
|
ln -s ../hyperlpr3/lib/lib* .
|
||||||
|
|
||||||
@@ -155,13 +155,13 @@ Copy the files you need into your project
|
|||||||
```bash
|
```bash
|
||||||
# go to Prj-linux
|
# go to Prj-linux
|
||||||
cd Prj-Linux
|
cd Prj-Linux
|
||||||
# make build and enter
|
# exec sh
|
||||||
mkdir build && cd build
|
sh build.sh
|
||||||
# Start compiling
|
|
||||||
cmake .. && make -j
|
|
||||||
```
|
```
|
||||||
The executable program is generated after compilation: **PlateRecDemo**,and Run the program
|
The executable program is generated after compilation: **PlateRecDemo**,and Run the program
|
||||||
```bash
|
```bash
|
||||||
|
# go to build
|
||||||
|
cd build/
|
||||||
# first param models dir, second param image path
|
# first param models dir, second param image path
|
||||||
./PlateRecDemo ../hyperlpr3/resource/models/r2_mobile ../hyperlpr3/resource/images/test_img.jpg
|
./PlateRecDemo ../hyperlpr3/resource/models/r2_mobile ../hyperlpr3/resource/images/test_img.jpg
|
||||||
```
|
```
|
||||||
@@ -234,7 +234,46 @@ Compiled to the: **build/release_android/**,Which contains:
|
|||||||
|
|
||||||
After compiling,Copy**arm64-v8a**and**armeabi-v7a** dirs to **Prj-Android/hyperlpr3/libs**,And compile the **Prj-Android** project to use.
|
After compiling,Copy**arm64-v8a**and**armeabi-v7a** dirs to **Prj-Android/hyperlpr3/libs**,And compile the **Prj-Android** project to use.
|
||||||
|
|
||||||
###
|
### 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:
|
||||||
|
|
||||||
|
```java
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
...
|
||||||
|
maven { url 'https://jitpack.io' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- Step 2. Add the dependency
|
||||||
|
```
|
||||||
|
dependencies {
|
||||||
|
implementation 'com.github.HyperInspire:hyperlpr3-android-sdk:1.0.2'
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 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](./Prj-Android)**
|
||||||
|
|
||||||
|
|
||||||
### License Plate Type is Supported(Chinese)
|
### License Plate Type is Supported(Chinese)
|
||||||
|
|
||||||
|
|||||||
+44
-6
@@ -133,7 +133,7 @@ A:此项目来源于作者早期的研究和调试代码,代码缺少一定
|
|||||||
|
|
||||||
### C/C++编译依赖库
|
### C/C++编译依赖库
|
||||||
|
|
||||||
编译C/C++工程需要使用第三方依赖库,将库下载后解压,并将其通过拷贝或软链接放入根目录(与CMakeLists.txt同级)即可,依赖的库下载地址:[百度网盘](https://pan.baidu.com/s/138O2bSlPN0H81OYP6zc3yQ) code: 5duf
|
编译C/C++工程需要使用第三方依赖库,将库下载后解压,并将其通过拷贝或软链接放入根目录(与CMakeLists.txt同级)即可,依赖的库下载地址:[百度网盘](https://pan.baidu.com/s/1hd3u3gLXid7UY5NusnxM6g) code: tunm
|
||||||
|
|
||||||
### Linux/Mac动态链接库编译
|
### Linux/Mac动态链接库编译
|
||||||
|
|
||||||
@@ -158,13 +158,13 @@ sh command/build_release_linux_share.sh
|
|||||||
```bash
|
```bash
|
||||||
# 进入到子工程demo
|
# 进入到子工程demo
|
||||||
cd Prj-Linux
|
cd Prj-Linux
|
||||||
# 创建build文件夹并进入
|
# 执行编译脚本
|
||||||
mkdir build && cd build
|
sh build.sh
|
||||||
# 开始编译
|
|
||||||
cmake .. && make -j
|
|
||||||
```
|
```
|
||||||
编译完成后生成可执行程序**PlateRecDemo**,执行运行测试
|
编译完成后生成可执行程序**PlateRecDemo**,执行运行测试
|
||||||
```bash
|
```bash
|
||||||
|
# 进入编译目录
|
||||||
|
cd build/
|
||||||
# 传入模型文件夹路径和需要预测的图像执行程序
|
# 传入模型文件夹路径和需要预测的图像执行程序
|
||||||
./PlateRecDemo ../hyperlpr3/resource/models/r2_mobile ../hyperlpr3/resource/images/test_img.jpg
|
./PlateRecDemo ../hyperlpr3/resource/models/r2_mobile ../hyperlpr3/resource/images/test_img.jpg
|
||||||
```
|
```
|
||||||
@@ -237,7 +237,45 @@ sh command/build_release_android_share.sh
|
|||||||
|
|
||||||
完成Android的动态库编译后,将**arm64-v8a**和**armeabi-v7a**文件夹放置于子项目路径**Prj-Android/hyperlpr3/libs**中,再编译android项目即可使用。**Prj-Android**项目中已内置hyperlpr3的SDK与使用demo。
|
完成Android的动态库编译后,将**arm64-v8a**和**armeabi-v7a**文件夹放置于子项目路径**Prj-Android/hyperlpr3/libs**中,再编译android项目即可使用。**Prj-Android**项目中已内置hyperlpr3的SDK与使用demo。
|
||||||
|
|
||||||
###
|
### Android-SDK示例工程
|
||||||
|
|
||||||
|
我们提供了一个Android-SDK相关的Demo工程:[hyperlpr3-android-sdk](https://github.com/HyperInspire/hyperlpr3-android-sdk.git),您可以根据需求去编译动态库使用该项目。
|
||||||
|
|
||||||
|
### 在Android中快速集成HyperLPR
|
||||||
|
|
||||||
|
如果你需要快速将我们的sdk集成到你自己的Android项目中,那么你可以将以下依赖添加到项目的build.gradle中:
|
||||||
|
|
||||||
|
- 步骤 1. 将JitPack仓库添加到构建文件中。将其添加到根构建中。在仓库末尾添加Gradle:
|
||||||
|
|
||||||
|
```
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
...
|
||||||
|
maven { url 'https://jitpack.io' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 步骤 2. 添加以下依赖
|
||||||
|
```
|
||||||
|
dependencies {
|
||||||
|
implementation 'com.github.HyperInspire:hyperlpr3-android-sdk:1.0.2'
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 步骤 3. 在应用程序中使用hyperlpr
|
||||||
|
|
||||||
|
```java
|
||||||
|
// 初始化通常在程序初始化时执行,只需执行一次
|
||||||
|
HyperLPR3.getInstance().init(this, new HyperLPRParameter());
|
||||||
|
|
||||||
|
…
|
||||||
|
|
||||||
|
// 识别一张图像
|
||||||
|
Plate[] plates = HyperLPR3.getInstance().plateRecognition(bitmap, HyperLPR3.CAMERA_ROTATION_0, HyperLPR3.STREAM_BGRA);
|
||||||
|
```
|
||||||
|
|
||||||
|
关于快速集成到安卓工程可以查看: **[Prj-Android](./Prj-Android)**
|
||||||
|
|
||||||
### 可识别和待支持的车牌的类型(中文)
|
### 可识别和待支持的车牌的类型(中文)
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ BUILD_DIR=build/linux
|
|||||||
mkdir -p ${BUILD_DIR}
|
mkdir -p ${BUILD_DIR}
|
||||||
cd ${BUILD_DIR}
|
cd ${BUILD_DIR}
|
||||||
|
|
||||||
cmake -DBUILD_SHARE=ON -DBUILD_SAMPLES=OFF -DBUILD_TEST=OFF ../..
|
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARE=ON -DBUILD_SAMPLES=OFF -DBUILD_TEST=OFF ../..
|
||||||
make -j4
|
make -j4
|
||||||
make install
|
make install
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user