Add Android Demo
This commit is contained in:
Generated
+23
-9
@@ -11,13 +11,27 @@
|
||||
</configurations>
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="4be586f9-7a61-4585-994f-eaa32375497d" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
|
||||
<list default="true" id="4be586f9-7a61-4585-994f-eaa32375497d" name="Changes" comment="Changes">
|
||||
<change afterPath="$PROJECT_DIR$/Prj-Android/app/src/main/res/values/themes.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/Prj-Android/hyperlpr3/src/main/AndroidManifest.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/Prj-Android/hyperlpr3/src/main/assets/r2_mobile/rpv3_mdict_160_r3.mnn" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/images/apk.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Prj-Python/hyperlpr3/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Python/hyperlpr3/__init__.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Prj-Python/hyperlpr3/config/configuration.py" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Python/hyperlpr3/config/configuration.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Prj-Python/hyperlpr3/config/settings.py" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Python/hyperlpr3/config/settings.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Prj-Python/setup.py" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Python/setup.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Prj-Android/app/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Android/app/build.gradle" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Prj-Android/app/src/main/java/com/hyperai/hyperlpr_sdk_demo/CameraActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Android/app/src/main/java/com/hyperai/hyperlpr_sdk_demo/CameraActivity.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Prj-Android/app/src/main/java/com/hyperai/hyperlpr_sdk_demo/MainActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Android/app/src/main/java/com/hyperai/hyperlpr_sdk_demo/MainActivity.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Prj-Android/app/src/main/res/layout/activity_main.xml" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Android/app/src/main/res/layout/activity_main.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Prj-Android/app/src/main/res/values/strings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Android/app/src/main/res/values/strings.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Prj-Android/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Android/build.gradle" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Prj-Android/hyperlpr3/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Android/hyperlpr3/build.gradle" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Prj-Android/hyperlpr3/src/main/assets/r2_mobile/rpv3_mdict_160h.mnn" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Prj-Android/hyperlpr3/src/main/java/com/hyperai/hyperlpr3/HyperLPR3.java" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Android/hyperlpr3/src/main/java/com/hyperai/hyperlpr3/HyperLPR3.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Prj-Android/hyperlpr3/src/main/java/com/hyperai/hyperlpr3/api/APIDefine.java" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Android/hyperlpr3/src/main/java/com/hyperai/hyperlpr3/api/APIDefine.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Prj-Android/hyperlpr3/src/main/java/com/hyperai/hyperlpr3/core/HyperLPRCore.java" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Android/hyperlpr3/src/main/java/com/hyperai/hyperlpr3/core/HyperLPRCore.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Prj-Android/settings.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Android/settings.gradle" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cpp/platform/jni/android/hyperlpr_native.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/cpp/platform/jni/android/hyperlpr_native.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cpp/src/context_module/hyper_lpr_context.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/cpp/src/context_module/hyper_lpr_context.cpp" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -64,17 +78,17 @@
|
||||
<property name="cf.first.check.clang-format" value="false" />
|
||||
<property name="cidr.known.project.marker" value="true" />
|
||||
<property name="cmake.loaded.for.project" value="true" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/resource/models" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/images" />
|
||||
<property name="nodejs_package_manager_path" value="npm" />
|
||||
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
|
||||
</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="$PROJECT_DIR$/images" />
|
||||
<recent name="$PROJECT_DIR$/resource/models" />
|
||||
<recent name="$PROJECT_DIR$/resource/models/r2_mobile" />
|
||||
<recent name="$PROJECT_DIR$/command" />
|
||||
<recent name="$PROJECT_DIR$/cpp/samples" />
|
||||
<recent name="$PROJECT_DIR$/tools/rknn_export_repo" />
|
||||
</key>
|
||||
<key name="MoveFile.RECENT_KEYS">
|
||||
<recent name="$PROJECT_DIR$/Prj-Python" />
|
||||
@@ -125,7 +139,7 @@
|
||||
<workItem from="1677218101830" duration="1207000" />
|
||||
<workItem from="1677220611638" duration="33000" />
|
||||
<workItem from="1677457111481" duration="10241000" />
|
||||
<workItem from="1677496149958" duration="3480000" />
|
||||
<workItem from="1677496149958" duration="6514000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
||||
@@ -41,4 +41,5 @@ dependencies {
|
||||
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'
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
@@ -48,8 +48,6 @@ public class CameraActivity extends Activity {
|
||||
private void initCamera() {
|
||||
previewFl = findViewById(R.id.preview_fl);
|
||||
plateTv = findViewById(R.id.plate_tv);
|
||||
// regTv = findViewById(R.id.reg_tv);
|
||||
// regTv.setOnClickListener(this);
|
||||
image = findViewById(R.id.image);
|
||||
cameraPreview = new CameraPreviews(this);
|
||||
previewFl.addView(cameraPreview);
|
||||
@@ -103,10 +101,4 @@ public class CameraActivity extends Activity {
|
||||
|
||||
// stopPreview();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// CameraPreviews cameraPreview = new CameraPreviews(this);
|
||||
// previewFl.addView(cameraPreview);
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -4,18 +4,45 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.hyperai.hyperlpr3.HyperLPR3;
|
||||
import com.hyperai.hyperlpr3.bean.Parameter;
|
||||
import com.hyperai.hyperlpr3.bean.Plate;
|
||||
import com.yuyh.library.imgsel.ISNav;
|
||||
import com.yuyh.library.imgsel.common.ImageLoader;
|
||||
import com.yuyh.library.imgsel.config.ISListConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private Button cameraBtn;
|
||||
private Button albumBtn;
|
||||
private Context mCtx;
|
||||
private static final int REQUEST_LIST_CODE = 0;
|
||||
private static final int REQUEST_CAMERA_CODE = 1;
|
||||
|
||||
private final String TAG = "HyperLPR-App";
|
||||
|
||||
private ImageView imageView;
|
||||
|
||||
private TextView mResult;
|
||||
|
||||
HyperLPR3 hyperLPR3;
|
||||
|
||||
|
||||
private static final int REQUEST_EXTERNAL_STORAGE = 1;
|
||||
@@ -45,10 +72,25 @@ public class MainActivity extends AppCompatActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
mCtx = this;
|
||||
cameraBtn = findViewById(R.id.cameraBtn);
|
||||
albumBtn = findViewById(R.id.albumBtn);
|
||||
imageView = findViewById(R.id.imageView);
|
||||
mResult = findViewById(R.id.mResult);
|
||||
|
||||
verifyStoragePermissions(this);
|
||||
|
||||
|
||||
Parameter parameter = new Parameter();
|
||||
hyperLPR3 = new HyperLPR3(mCtx, parameter);
|
||||
|
||||
ISNav.getInstance().init(new ImageLoader() {
|
||||
@Override
|
||||
public void displayImage(Context context, String path, ImageView imageView) {
|
||||
Glide.with(context).load(path).into(imageView);
|
||||
}
|
||||
});
|
||||
|
||||
cameraBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
@@ -61,8 +103,72 @@ public class MainActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
// 自由配置选项
|
||||
ISListConfig config = new ISListConfig.Builder()
|
||||
// 是否多选, 默认true
|
||||
.multiSelect(false)
|
||||
// 是否记住上次选中记录, 仅当multiSelect为true的时候配置,默认为true
|
||||
.rememberSelected(false)
|
||||
// “确定”按钮背景色
|
||||
.btnBgColor(Color.GRAY)
|
||||
// “确定”按钮文字颜色
|
||||
.btnTextColor(Color.BLUE)
|
||||
// 使用沉浸式状态栏
|
||||
.statusBarColor(Color.parseColor("#3F51B5"))
|
||||
// 返回图标ResId
|
||||
.backResId(androidx.appcompat.R.drawable.abc_cab_background_top_mtrl_alpha)
|
||||
// 标题
|
||||
.title("图片")
|
||||
// 标题文字颜色
|
||||
.titleColor(Color.WHITE)
|
||||
// TitleBar背景色
|
||||
.titleBgColor(Color.parseColor("#3F51B5"))
|
||||
// 裁剪大小。needCrop为true的时候配置
|
||||
.cropSize(1, 1, 200, 200)
|
||||
.needCrop(false)
|
||||
// 第一个是否显示相机,默认true
|
||||
.needCamera(false)
|
||||
// 最大选择图片数量,默认9
|
||||
.maxNum(1)
|
||||
.build();
|
||||
|
||||
// 跳转到图片选择器
|
||||
ISNav.getInstance().toListActivity(mCtx, config, REQUEST_LIST_CODE);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
Bitmap bitmap = null;
|
||||
String showText = "";
|
||||
// 图片选择结果回调
|
||||
if (requestCode == REQUEST_LIST_CODE && resultCode == RESULT_OK && data != null) {
|
||||
List<String> pathList = data.getStringArrayListExtra("result");
|
||||
Log.i(TAG, pathList.get(0));
|
||||
bitmap = BitmapFactory.decodeFile(pathList.get(0));
|
||||
} else if (requestCode == REQUEST_CAMERA_CODE && resultCode == RESULT_OK && data != null) {
|
||||
String path = data.getStringExtra("result");
|
||||
Log.i(TAG, path);
|
||||
bitmap = BitmapFactory.decodeFile(path);
|
||||
}
|
||||
if (bitmap != null) {
|
||||
|
||||
imageView.setImageBitmap(bitmap);
|
||||
Plate[] plates = hyperLPR3.plateRecognition(bitmap, HyperLPR3.CAMERA_ROTATION_0, HyperLPR3.STREAM_BGRA);
|
||||
for (Plate plate: plates) {
|
||||
String type = "未知车牌";
|
||||
if (plate.getType() != HyperLPR3.PLATE_TYPE_UNKNOWN) {
|
||||
type = HyperLPR3.PLATE_TYPE_MAPS[plate.getType()];
|
||||
}
|
||||
String pStr = "[" + type + "]" + plate.getCode() + "\n";
|
||||
showText += pStr;
|
||||
mResult.setText(showText);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,28 +6,52 @@
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<Button
|
||||
android:id="@+id/cameraBtn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="打开相机"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.2"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.863" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/albumBtn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="打开相册"
|
||||
android:text="选择图片识别"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.776"
|
||||
app:layout_constraintHorizontal_bias="0.791"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.863" />
|
||||
app:layout_constraintVertical_bias="0.923" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/cameraBtn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="实时车牌识别"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.217"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.923" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="297dp"
|
||||
android:layout_height="419dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.227"
|
||||
tools:srcCompat="@tools:sample/avatars" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/mResult"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.233"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView"
|
||||
app:layout_constraintVertical_bias="0.079" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,3 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">HyperLPR_SDK_Demo</string>
|
||||
<string name="app_name">HyperLPR3-App</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,16 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.HyperLPR_SDK_Demo" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_500</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorOnPrimary">@color/white</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/teal_200</item>
|
||||
<item name="colorSecondaryVariant">@color/teal_700</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
||||
@@ -3,7 +3,6 @@ buildscript {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
maven { url "https://jitpack.io" }
|
||||
}
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:7.0.2"
|
||||
|
||||
@@ -44,4 +44,5 @@ dependencies {
|
||||
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'
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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.
@@ -1,6 +1,7 @@
|
||||
package com.hyperai.hyperlpr3;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.Log;
|
||||
|
||||
import com.hyperai.hyperlpr3.api.APIDefine;
|
||||
@@ -60,5 +61,22 @@ public class HyperLPR3 extends TypeDefine implements APIDefine {
|
||||
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) {
|
||||
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,5 +1,7 @@
|
||||
package com.hyperai.hyperlpr3.api;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import com.hyperai.hyperlpr3.bean.Plate;
|
||||
|
||||
public interface APIDefine {
|
||||
@@ -15,4 +17,13 @@ public interface APIDefine {
|
||||
*/
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
@@ -31,6 +31,10 @@ public class HyperLPRCore {
|
||||
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_) {
|
||||
@@ -50,4 +54,8 @@ public class HyperLPRCore {
|
||||
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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ dependencyResolutionManagement {
|
||||
google()
|
||||
mavenCentral()
|
||||
jcenter() // Warning: this repository is going to shut down soon
|
||||
maven { url "https://jitpack.io" }
|
||||
}
|
||||
}
|
||||
rootProject.name = "HyperLPR_SDK_Demo"
|
||||
|
||||
@@ -241,7 +241,9 @@ sh command/build_release_android_share.sh
|
||||
|
||||
### 识别测试APP(老版)
|
||||
|
||||
- 体验 Android APP:[http://demo.zeusee.com/HyperLPR](http://demo.zeusee.com/HyperLPR) (根据图片尺寸调整程序中的尺度,提高准确率)
|
||||
- 体验 Android APP(扫码下载):
|
||||
|
||||

|
||||
|
||||
#### 获取帮助
|
||||
|
||||
|
||||
@@ -90,6 +90,76 @@ JNIEXPORT int JNICALL HYPERLPR_API(core_HyperLPRCore_ReleaseRecognizerContext) (
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jobjectArray JNICALL HYPERLPR_API(core_HyperLPRCore_PlateRecognitionFromImage) (
|
||||
JNIEnv *env,
|
||||
jobject thiz,
|
||||
jlong handle,
|
||||
jintArray buf,
|
||||
jint height,
|
||||
jint width,
|
||||
jint rotation,
|
||||
jint format) {
|
||||
P_HLPR_Context ctx = (P_HLPR_Context ) handle;
|
||||
jint *pBuf = env->GetIntArrayElements(buf, 0);
|
||||
// create ImageData
|
||||
HLPR_ImageData data = {0};
|
||||
data.data = (uint8_t *)pBuf;
|
||||
data.width = width;
|
||||
data.height = height;
|
||||
data.format = HLPR_ImageFormat(format);
|
||||
data.rotation = HLPR_Rotation(rotation);
|
||||
// create DataBuffer
|
||||
P_HLPR_DataBuffer buffer = HLPR_CreateDataBuffer(&data);
|
||||
|
||||
// exec plate recognition
|
||||
HLPR_PlateResultList results = {0};
|
||||
cost_ = (double)cv::getTickCount();
|
||||
HLPR_ContextUpdateStream(ctx, buffer, &results);
|
||||
cost_ = ((double)cv::getTickCount() - cost_) / cv::getTickFrequency();
|
||||
LOGD("cost: %f", cost_);
|
||||
|
||||
jobjectArray jPlateArray = nullptr;
|
||||
jclass jPlateCls = env->FindClass("com/hyperai/hyperlpr3/bean/Plate");
|
||||
// get object method id
|
||||
jmethodID plateClsInitId = env->GetMethodID(jPlateCls, "<init>", "()V");
|
||||
jmethodID setX1MethodId = env->GetMethodID(jPlateCls, "setX1", "(F)V");
|
||||
jmethodID setY1MethodId = env->GetMethodID(jPlateCls, "setY1", "(F)V");
|
||||
jmethodID setX2MethodId = env->GetMethodID(jPlateCls, "setX2", "(F)V");
|
||||
jmethodID setY2MethodId = env->GetMethodID(jPlateCls, "setY2", "(F)V");
|
||||
// jmethodID setLayersMethodId = env->GetMethodID(jPlateCls, "setLayers", "(I)V");
|
||||
jmethodID setTypeMethodId = env->GetMethodID(jPlateCls, "setType", "(I)V");
|
||||
jmethodID setConfidenceMethodId = env->GetMethodID(jPlateCls, "setConfidence", "(F)V");
|
||||
jmethodID setCodeMethodId = env->GetMethodID(jPlateCls, "setCode", "(Ljava/lang/String;)V");
|
||||
|
||||
int total = results.plate_size;
|
||||
jPlateArray = env->NewObjectArray(total, jPlateCls, 0);
|
||||
for (int i = 0; i < total; ++i) {
|
||||
auto &plate = results.plates[i];
|
||||
// set in location
|
||||
jobject jPlate = env->NewObject(jPlateCls, plateClsInitId);
|
||||
env->CallVoidMethod(jPlate, setX1MethodId, plate.x1);
|
||||
env->CallVoidMethod(jPlate, setY1MethodId, plate.y1);
|
||||
env->CallVoidMethod(jPlate, setX2MethodId, plate.x2);
|
||||
env->CallVoidMethod(jPlate, setY2MethodId, plate.y2);
|
||||
// set in types
|
||||
// env->CallVoidMethod(jPlate, setLayersMethodId, plate.layers);
|
||||
env->CallVoidMethod(jPlate, setTypeMethodId, plate.type);
|
||||
// set in text_confidence
|
||||
env->CallVoidMethod(jPlate, setConfidenceMethodId, plate.text_confidence);
|
||||
// set in plate code
|
||||
// env->CallObjectMethod(jPlate, setCodeMethodId, stringTojstring(env, plate.code));
|
||||
env->CallObjectMethod(jPlate, setCodeMethodId, env->NewStringUTF(plate.code));
|
||||
|
||||
env->SetObjectArrayElement(jPlateArray, i, jPlate);
|
||||
env->DeleteLocalRef(jPlate);
|
||||
}
|
||||
env->DeleteLocalRef(jPlateCls);
|
||||
|
||||
return jPlateArray;
|
||||
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jobjectArray JNICALL HYPERLPR_API(core_HyperLPRCore_PlateRecognitionFromBuffer) (
|
||||
JNIEnv *env,
|
||||
jobject thiz,
|
||||
|
||||
@@ -88,7 +88,7 @@ void HyperLPRContext::operator()(CameraBuffer &buffer) {
|
||||
// obj.color_classify = PlateColor::GREEN;
|
||||
// obj.layers = loc.layers;
|
||||
// LOGD("size %d", text_line.code.size());
|
||||
if (text_line.code.size() >= 7) {
|
||||
if (text_line.code.size() >= 8) {
|
||||
obj.text_confidence = text_line.average_score;
|
||||
auto type = PreGetPlateType(text_line.code);
|
||||
if (type == PlateType::UNKNOWN) {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
Reference in New Issue
Block a user