README
This commit is contained in:
@@ -3,12 +3,12 @@ plugins {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk 28
|
||||
compileSdk 31
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.hyperai.hyperlpr_sdk_demo"
|
||||
minSdk 22
|
||||
targetSdk 28
|
||||
applicationId "com.hyperai.example.lpr3_demo"
|
||||
minSdk 21
|
||||
targetSdk 31
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
@@ -29,17 +29,17 @@ android {
|
||||
|
||||
dependencies {
|
||||
|
||||
// Tools
|
||||
implementation 'org.greenrobot:eventbus:3.0.0'
|
||||
implementation 'com.android.support:appcompat-v7:28.0.0'
|
||||
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
|
||||
implementation 'com.github.smuyyh:ImageSelector:3.0'
|
||||
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 'com.google.android.material:material:1.3.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||
implementation project(path: ':hyperlpr3')
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
testImplementation 'junit:junit:4.+'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
implementation 'com.github.smuyyh:ImageSelector:3.0'
|
||||
implementation 'com.github.bumptech.glide:glide:3.7.0'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||
}
|
||||
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;
|
||||
|
||||
@@ -21,6 +21,6 @@ public class ExampleInstrumentedTest {
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
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"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
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.autofocus" />
|
||||
@@ -38,7 +38,7 @@
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.HyperLPR_SDK_Demo">
|
||||
android:theme="@style/Theme.HyperLPR3Example">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
@@ -49,11 +49,6 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".CameraActivity" />
|
||||
<!-- <activity-->
|
||||
<!-- android:name=".CameraPlate"-->
|
||||
<!-- android:screenOrientation="landscape"-->
|
||||
<!-- >-->
|
||||
<!-- </activity>-->
|
||||
</application>
|
||||
|
||||
</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.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
import com.hyperai.hyperlpr3.HyperLPR3;
|
||||
import com.hyperai.hyperlpr3.bean.Plate;
|
||||
|
||||
@@ -20,9 +16,6 @@ import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author by hs-johnny
|
||||
@@ -33,7 +26,6 @@ public class CameraActivity extends Activity {
|
||||
FrameLayout previewFl;
|
||||
CameraPreviews cameraPreview;
|
||||
TextView plateTv;
|
||||
// TextView regTv;
|
||||
ImageView image;
|
||||
|
||||
@Override
|
||||
@@ -98,7 +90,6 @@ public class CameraActivity extends Activity {
|
||||
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.graphics.Paint;
|
||||
import android.hardware.Camera;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
//import android.support.v4.content.ContextCompat;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.MotionEvent;
|
||||
@@ -14,16 +13,15 @@ import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
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 java.io.IOException;
|
||||
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
|
||||
* 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.setStrokeWidth(2);
|
||||
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(){
|
||||
if (mCamera == null){
|
||||
@@ -137,7 +131,6 @@ public class CameraPreviews extends SurfaceView implements SurfaceHolder.Callbac
|
||||
}
|
||||
|
||||
if(!isStopReg && plates.length > 0) {
|
||||
// isStopReg = true;
|
||||
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.core.app.ActivityCompat;
|
||||
@@ -27,7 +27,6 @@ import com.yuyh.library.imgsel.config.ISListConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private Button cameraBtn;
|
||||
@@ -78,7 +77,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
verifyStoragePermissions(this);
|
||||
|
||||
|
||||
// 车牌识别算法配置参数
|
||||
HyperLPRParameter parameter = new HyperLPRParameter()
|
||||
.setDetLevel(HyperLPR3.DETECT_LEVEL_LOW)
|
||||
@@ -161,6 +159,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
if (bitmap != null) {
|
||||
|
||||
imageView.setImageBitmap(bitmap);
|
||||
// 调用车牌识别
|
||||
Plate[] plates = HyperLPR3.getInstance().plateRecognition(bitmap, HyperLPR3.CAMERA_ROTATION_0, HyperLPR3.STREAM_BGRA);
|
||||
for (Plate plate: plates) {
|
||||
String type = "未知车牌";
|
||||
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
@@ -1,3 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">HyperLPR3-App</string>
|
||||
<string name="app_name">HyperLPR3-Example</string>
|
||||
</resources>
|
||||
@@ -1,6 +1,6 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- 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. -->
|
||||
<item name="colorPrimary">@color/purple_500</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;
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
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
|
||||
// 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
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
|
||||
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()
|
||||
mavenCentral()
|
||||
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 ':hyperlpr3'
|
||||
|
||||
Reference in New Issue
Block a user