├── .gitignore
├── .idea
├── .gitignore
├── .name
├── compiler.xml
├── gradle.xml
├── misc.xml
└── vcs.xml
├── LICENSE
├── README.md
├── README_CH.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
├── release
│ ├── hyperlpr3-demo.apk
│ └── output-metadata.json
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── hyperai
│ │ └── hyperlpr_sdk_demo
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── hyperai
│ │ │ └── hyperlpr_sdk_demo
│ │ │ ├── CameraActivity.java
│ │ │ ├── CameraPreviews.java
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ ├── activity_camera.xml
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.webp
│ │ ├── ic_launcher_round.webp
│ │ └── logo.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── values-night
│ │ └── themes.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── com
│ └── hyperai
│ └── hyperlpr_sdk_demo
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── hyperlpr3
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── libs
│ ├── arm64-v8a
│ │ └── libhyperlpr3.so
│ └── armeabi-v7a
│ │ └── libhyperlpr3.so
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── hyperai
│ │ └── hyperlpr3
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ └── r2_mobile
│ │ │ ├── b320_backbone_h.mnn
│ │ │ ├── b320_header_h.mnn
│ │ │ ├── b640x_backbone_h.mnn
│ │ │ ├── b640x_head_h.mnn
│ │ │ ├── litemodel_cls_96xh.mnn
│ │ │ └── rpv3_mdict_160h.mnn
│ └── java
│ │ └── com
│ │ └── hyperai
│ │ └── hyperlpr3
│ │ ├── HyperLPR3.java
│ │ ├── api
│ │ └── APIDefine.java
│ │ ├── bean
│ │ ├── HyperLPRParameter.java
│ │ └── Plate.java
│ │ ├── core
│ │ └── HyperLPRCore.java
│ │ ├── settings
│ │ ├── SDKConfig.java
│ │ └── TypeDefine.java
│ │ └── utils
│ │ └── SDKUtils.java
│ └── test
│ └── java
│ └── com
│ └── hyperai
│ └── hyperlpr3
│ └── ExampleUnitTest.java
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | HyperLPR_SDK_Demo
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
20 |
21 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## HyperLPR3-License Plate Recognition Android SDK
2 |
3 | [中文文档](README_CH.md)
4 |
5 | High performance license plate recognition based on deep learning HyperLPR Android SDK implementation.
6 |
7 | ### Source Code Project
8 |
9 | If you need to learn about the build steps in the source code of the project, you can go : [HyperLPR](https://github.com/szad670401/HyperLPR).
10 |
11 | ### Supporting Platform
12 |
13 | - Android: arm64-v8a、armeabi-v7a
14 |
15 | ### Add Dependency
16 |
17 | Add Jitpack dependencies to your Gradle configuration
18 |
19 | ```java
20 | allprojects {
21 | repositories {
22 | ...
23 | maven { url 'https://jitpack.io' }
24 | }
25 | }
26 | ```
27 |
28 | Add dependencies in build.gradle for projects where you need hyperlpr
29 |
30 | ```java
31 | dependencies {
32 | implementation 'com.github.HyperInspire:hyperlpr3-android-sdk:1.0.3'
33 | }
34 | ```
35 |
36 | ### How to Use
37 |
38 | #### Initialize HyperLPR
39 |
40 | Before implementing the license plate recognition algorithm, the initialization function needs to be executed, and the storage read and write permissions need to be opened in advance. Initialization is performed only once, usually when the program is started.
41 |
42 | ```Java
43 | // License plate recognition algorithm configuration parameters
44 | HyperLPRParameter parameter = new HyperLPRParameter()
45 | .setDetLevel(HyperLPR3.DETECT_LEVEL_LOW)
46 | .setMaxNum(1)
47 | .setRecConfidenceThreshold(0.85f);
48 | // Initialization (performed only once)
49 | HyperLPR3.getInstance().init(this, parameter);
50 | ```
51 |
52 | #### License plate recognition on an image
53 |
54 | Bitmap is used as an example for license plate recognition
55 |
56 | ```Java
57 | // Use Bitmap as picture parameter for license plate recognition
58 | Plate[] plates = HyperLPR3.getInstance().plateRecognition(bitmap, HyperLPR3.CAMERA_ROTATION_0, HyperLPR3.STREAM_BGRA);
59 | for (Plate plate: plates) {
60 | // Print the detected license plate number
61 | Log.i(TAG, plate.getCode());
62 | }
63 |
64 | ```
65 | #### License plate recognition on an steam
66 |
67 | License plate recognition using camera stream or file stream
68 |
69 | ```Java
70 | // License plate recognition using a stream of NV21
71 | Plate[] plates = HyperLPR3.getInstance().plateRecognition(data, previewSize.height, previewSize.width, HyperLPR3.CAMERA_ROTATION_270, HyperLPR3.STREAM_YUV_NV21);
72 | ```
73 |
74 | #### Note
75 |
76 | The Android-SDK of hyperlpr is currently in the testing phase. If you encounter any problems during use, please raise your questions in issues. PR welcome.
--------------------------------------------------------------------------------
/README_CH.md:
--------------------------------------------------------------------------------
1 | ## HyperLPR3-Android-SDK HyperLPR3-车牌识别安卓SDK
2 |
3 | 基于深度学习高性能车牌识别HyperLPR的安卓SDK实现
4 |
5 | ### 源码工程
6 |
7 | 需要了解编译相关源码可移步到[HyperLPR工程](https://github.com/szad670401/HyperLPR)。
8 |
9 | ### 支持平台
10 |
11 | - Android: arm64-v8a、armeabi-v7a
12 |
13 | ### 添加依赖
14 |
15 | 在你的Gradle配置中添加Jitpack依赖
16 |
17 | ```java
18 | allprojects {
19 | repositories {
20 | ...
21 | maven { url 'https://jitpack.io' }
22 | }
23 | }
24 | ```
25 |
26 | 在你需要使用hyperlpr的项目中的build.gradle添加依赖
27 |
28 | ```java
29 | dependencies {
30 | implementation 'com.github.HyperInspire:hyperlpr3-android-sdk:1.0.3'
31 | }
32 | ```
33 |
34 | ### 如何使用
35 |
36 |
37 | #### 初始化HyperLPR
38 |
39 | 在执行车牌识别算法之前需要先执行初始化函数,需要提前开启存储读写权限;初始化仅需执行一次,通常在程序启动的时候执行。
40 |
41 | ```Java
42 | // 车牌识别算法配置参数
43 | HyperLPRParameter parameter = new HyperLPRParameter()
44 | .setDetLevel(HyperLPR3.DETECT_LEVEL_LOW)
45 | .setMaxNum(1)
46 | .setRecConfidenceThreshold(0.85f);
47 | // 初始化(仅执行一次生效)
48 | HyperLPR3.getInstance().init(this, parameter);
49 | ```
50 |
51 | #### 对一张图片进行车牌识别
52 |
53 | 采用Bitmap作为示例进行车牌识别
54 |
55 | ```Java
56 | // 使用Bitmap作为图片参数进行车牌识别
57 | Plate[] plates = HyperLPR3.getInstance().plateRecognition(bitmap, HyperLPR3.CAMERA_ROTATION_0, HyperLPR3.STREAM_BGRA);
58 | for (Plate plate: plates) {
59 | // 打印检测到的车牌号
60 | Log.i(TAG, plate.getCode());
61 | }
62 |
63 | ```
64 | #### 对流进行识别
65 |
66 | 通常可以传入相机流或文件流进行车牌识别
67 |
68 | ```Java
69 | // 使用一段NV21的流进行车牌识别
70 | Plate[] plates = HyperLPR3.getInstance().plateRecognition(data, previewSize.height, previewSize.width, HyperLPR3.CAMERA_ROTATION_270, HyperLPR3.STREAM_YUV_NV21);
71 | ```
72 |
73 | #### 注意
74 |
75 | hyperlpr的Android-SDK当前属于测试阶段,如果您在使用过程中遇到任何问题请在issues中提出你的问题,也很欢迎大家多提PR。
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | }
4 |
5 | android {
6 | compileSdk 28
7 |
8 | defaultConfig {
9 | applicationId "com.hyperai.hyperlpr_sdk_demo"
10 | minSdk 21
11 | targetSdk 28
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | compileOptions {
25 | sourceCompatibility JavaVersion.VERSION_1_8
26 | targetCompatibility JavaVersion.VERSION_1_8
27 | }
28 | }
29 |
30 | dependencies {
31 |
32 | implementation 'org.greenrobot:eventbus:3.0.0'
33 | implementation 'com.android.support:appcompat-v7:28.0.0'
34 | implementation 'com.android.support.constraint:constraint-layout:2.0.4'
35 |
36 | implementation 'androidx.appcompat:appcompat:1.2.0'
37 | implementation 'com.google.android.material:material:1.3.0'
38 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
39 | implementation project(path: ':hyperlpr3')
40 | testImplementation 'junit:junit:4.+'
41 | androidTestImplementation 'androidx.test.ext:junit:1.1.2'
42 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
43 | implementation 'com.github.smuyyh:ImageSelector:3.0'
44 | implementation 'com.github.bumptech.glide:glide:3.7.0'
45 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/release/hyperlpr3-demo.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/app/release/hyperlpr3-demo.apk
--------------------------------------------------------------------------------
/app/release/output-metadata.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "artifactType": {
4 | "type": "APK",
5 | "kind": "Directory"
6 | },
7 | "applicationId": "com.hyperai.hyperlpr_sdk_demo",
8 | "variantName": "release",
9 | "elements": [
10 | {
11 | "type": "SINGLE",
12 | "filters": [],
13 | "attributes": [],
14 | "versionCode": 1,
15 | "versionName": "1.0",
16 | "outputFile": "app-release.apk"
17 | }
18 | ],
19 | "elementType": "File"
20 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/hyperai/hyperlpr_sdk_demo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.hyperai.hyperlpr_sdk_demo;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 | assertEquals("com.hyperai.hyperlpr_sdk_demo", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
42 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hyperai/hyperlpr_sdk_demo/CameraActivity.java:
--------------------------------------------------------------------------------
1 | package com.hyperai.hyperlpr_sdk_demo;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.app.Activity;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.view.Window;
8 | import android.view.WindowManager;
9 | import android.widget.ArrayAdapter;
10 | import android.widget.FrameLayout;
11 | import android.widget.ImageView;
12 | import android.widget.ListView;
13 | import android.widget.TextView;
14 |
15 |
16 | import com.hyperai.hyperlpr3.HyperLPR3;
17 | import com.hyperai.hyperlpr3.bean.Plate;
18 |
19 | import org.greenrobot.eventbus.EventBus;
20 | import org.greenrobot.eventbus.Subscribe;
21 | import org.greenrobot.eventbus.ThreadMode;
22 |
23 | import java.util.ArrayList;
24 | import java.util.List;
25 |
26 |
27 | /**
28 | * @author by hs-johnny
29 | * Created on 2019/6/17
30 | */
31 | public class CameraActivity extends Activity {
32 |
33 | FrameLayout previewFl;
34 | CameraPreviews cameraPreview;
35 | TextView plateTv;
36 | // TextView regTv;
37 | ImageView image;
38 |
39 | @Override
40 | protected void onCreate(Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 | requestWindowFeature(Window.FEATURE_NO_TITLE);
43 | getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
44 | WindowManager.LayoutParams.FLAG_FULLSCREEN);
45 | setContentView(R.layout.activity_camera);
46 | }
47 |
48 | private void initCamera() {
49 | previewFl = findViewById(R.id.preview_fl);
50 | plateTv = findViewById(R.id.plate_tv);
51 | image = findViewById(R.id.image);
52 | cameraPreview = new CameraPreviews(this);
53 | previewFl.addView(cameraPreview);
54 | }
55 |
56 | @Override
57 | protected void onResume() {
58 | super.onResume();
59 | if (cameraPreview == null) {
60 | initCamera();
61 | }
62 | }
63 |
64 | @Override
65 | protected void onPause() {
66 | super.onPause();
67 | cameraPreview = null;
68 | }
69 |
70 | private void stopPreview() {
71 | previewFl.removeAllViews();
72 | }
73 |
74 | @Override
75 | protected void onStart() {
76 | super.onStart();
77 | EventBus.getDefault().register(this);
78 | }
79 |
80 | @Override
81 | protected void onStop() {
82 | super.onStop();
83 | EventBus.getDefault().unregister(this);
84 | }
85 |
86 | @SuppressLint("SetTextI18n")
87 | @Subscribe(threadMode = ThreadMode.MAIN)
88 | public void onMessageEvent(Plate[] plates) {
89 |
90 | String showText = "";
91 | for (Plate plate: plates) {
92 | String type = "未知车牌";
93 | if (plate.getType() != HyperLPR3.PLATE_TYPE_UNKNOWN) {
94 | type = HyperLPR3.PLATE_TYPE_MAPS[plate.getType()];
95 | }
96 | String pStr = "[" + type + "]" + plate.getCode() + "\n";
97 | showText += pStr;
98 | plateTv.setText(showText);
99 |
100 | }
101 |
102 | // stopPreview();
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hyperai/hyperlpr_sdk_demo/CameraPreviews.java:
--------------------------------------------------------------------------------
1 | package com.hyperai.hyperlpr_sdk_demo;
2 |
3 | import android.content.Context;
4 | import android.graphics.Paint;
5 | import android.hardware.Camera;
6 | import android.os.Handler;
7 | import android.os.HandlerThread;
8 | //import android.support.v4.content.ContextCompat;
9 | import android.util.Log;
10 | import android.view.Display;
11 | import android.view.MotionEvent;
12 | import android.view.Surface;
13 | import android.view.SurfaceHolder;
14 | import android.view.SurfaceView;
15 | import android.view.WindowManager;
16 |
17 |
18 | import org.greenrobot.eventbus.EventBus;
19 |
20 | import java.io.IOException;
21 | import java.util.List;
22 |
23 | import com.hyperai.hyperlpr3.HyperLPR3;
24 | import com.hyperai.hyperlpr3.bean.HyperLPRParameter;
25 | import com.hyperai.hyperlpr3.bean.Plate;
26 |
27 | /**
28 | * @author by hs-johnny
29 | * Created on 2019/6/17
30 | */
31 | public class CameraPreviews extends SurfaceView implements SurfaceHolder.Callback, Camera.PreviewCallback {
32 |
33 | private static final String TAG = "CameraPreview";
34 | private Camera mCamera;
35 | private SurfaceHolder mHolder;
36 | public long handle;
37 | private byte[] lock = new byte[0];
38 | private Paint mPaint;
39 | private float oldDist = 1f;
40 | /** 停止识别*/
41 | private boolean isStopReg;
42 |
43 | private Context mContext;
44 |
45 | public CameraPreviews(Context context) {
46 | super(context);
47 | mContext = context;
48 | mHolder = getHolder();
49 | mHolder.addCallback(this);
50 | mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
51 | mPaint.setStrokeWidth(2);
52 | mPaint.setStyle(Paint.Style.STROKE);
53 | // mPaint.setColor(ContextCompat.getColor(context, R.color.colorAccent));
54 |
55 | HyperLPRParameter parameter = new HyperLPRParameter();
56 | // hyperLPR3 = new HyperLPR3();
57 | // hyperLPR3.init(mContext, parameter);
58 | }
59 | public Camera getCameraInstance(){
60 | if (mCamera == null){
61 | try {
62 | CameraHandlerThread mThread = new CameraHandlerThread("camera thread");
63 | synchronized (mThread){
64 | mThread.openCamera();
65 | }
66 | }catch (Exception e){
67 | Log.e(TAG, "camera is not available" );
68 | }
69 | }
70 | return mCamera;
71 | }
72 |
73 | @Override
74 | public void surfaceCreated(SurfaceHolder holder) {
75 | mCamera = getCameraInstance();
76 | mCamera.setPreviewCallback(this);
77 | try {
78 | mCamera.setPreviewDisplay(mHolder);
79 | mCamera.startPreview();
80 | setPreviewFocus(mCamera);
81 | } catch (IOException e) {
82 | e.printStackTrace();
83 | }
84 | }
85 |
86 | @Override
87 | public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
88 | int rotation = getDisplayOrientation();
89 | mCamera.setDisplayOrientation(rotation);
90 | Camera.Parameters parameters = mCamera.getParameters();
91 | parameters.setRotation(rotation);
92 | // parameters.setPreviewFormat(ImageFormat.NV21);
93 | mCamera.setParameters(parameters);
94 | }
95 |
96 | @Override
97 | public void surfaceDestroyed(SurfaceHolder holder) {
98 | mHolder.removeCallback(this);
99 | mCamera.setPreviewCallback(null);
100 | mCamera.stopPreview();
101 | mCamera.release();
102 | mCamera = null;
103 | }
104 |
105 | public int getDisplayOrientation(){
106 | Display display = ((WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
107 | int rotation = display.getRotation();
108 | int degrees = 0;
109 | switch (rotation){
110 | case Surface.ROTATION_0:
111 | degrees = 0;
112 | break;
113 | case Surface.ROTATION_90:
114 | degrees = 90;
115 | break;
116 | case Surface.ROTATION_180:
117 | degrees = 180;
118 | break;
119 | case Surface.ROTATION_270:
120 | degrees = 270;
121 | break;
122 | }
123 | Camera.CameraInfo info = new Camera.CameraInfo();
124 | Camera.getCameraInfo(Camera.CameraInfo.CAMERA_FACING_BACK, info);
125 | int result = (info.orientation - degrees + 360) % 360;
126 | return result;
127 | }
128 |
129 | @Override
130 | public void onPreviewFrame(final byte[] data, final Camera camera) {
131 | synchronized (lock){
132 | // 处理data
133 | Camera.Size previewSize = camera.getParameters().getPreviewSize();
134 | Plate[] plates = HyperLPR3.getInstance().plateRecognition(data, previewSize.height, previewSize.width, HyperLPR3.CAMERA_ROTATION_270, HyperLPR3.STREAM_YUV_NV21);
135 | for (Plate plate : plates) {
136 | Log.i(TAG, "" + plate.toString());
137 | }
138 |
139 | if(!isStopReg && plates.length > 0) {
140 | // isStopReg = true;
141 | sendPlate(plates);
142 | }
143 |
144 | }
145 | }
146 |
147 | private void sendPlate(Plate[] plates){
148 | EventBus.getDefault().post(plates);
149 | }
150 |
151 |
152 | private void openCameraOriginal(){
153 | try {
154 | mCamera = Camera.open();
155 | }catch (Exception e){
156 | Log.e(TAG, "camera is not available");
157 | }
158 | }
159 |
160 | private class CameraHandlerThread extends HandlerThread {
161 | Handler handler;
162 | public CameraHandlerThread(String name) {
163 | super(name);
164 | start();
165 | handler = new Handler(getLooper());
166 | }
167 |
168 | synchronized void notifyCameraOpened(){
169 | notify();
170 | }
171 |
172 | void openCamera(){
173 | handler.post(new Runnable() {
174 | @Override
175 | public void run() {
176 | openCameraOriginal();
177 | notifyCameraOpened();
178 | }
179 | });
180 | try {
181 | wait();
182 | }catch (Exception e){
183 | Log.e(TAG, "wait was interrupted");
184 | }
185 | }
186 | }
187 |
188 | @Override
189 | public boolean onTouchEvent(MotionEvent event) {
190 | if(event.getPointerCount() == 2){
191 | switch (event.getAction()){
192 | case MotionEvent.ACTION_POINTER_DOWN:
193 | oldDist = getFingerSpacing(event);
194 | break;
195 | case MotionEvent.ACTION_MOVE:
196 | float newDist = getFingerSpacing(event);
197 | if(newDist > oldDist){
198 | handleZoom(true, mCamera);
199 | }else if(newDist < oldDist){
200 | handleZoom(false, mCamera);
201 | }
202 | oldDist = newDist;
203 | break;
204 | }
205 | }
206 | return true;
207 | }
208 |
209 | private float getFingerSpacing(MotionEvent event){
210 | float x = event.getX(0) - event.getX(1);
211 | float y = event.getY(0) - event.getY(1);
212 | return (float) Math.sqrt(x * x + y * y);
213 | }
214 |
215 | private void handleZoom(boolean isZoomIn, Camera camera){
216 | Camera.Parameters parameters = camera.getParameters();
217 | if (parameters.isZoomSupported()){
218 | int maxZoom = parameters.getMaxZoom();
219 | int zoom = parameters.getZoom();
220 | if (isZoomIn && zoom < maxZoom){
221 | zoom++;
222 | }else if(zoom > 0){
223 | zoom--;
224 | }
225 | parameters.setZoom(zoom);
226 | camera.setParameters(parameters);
227 | }else {
228 | Log.e(TAG, "handleZoom: "+"the device is not support zoom");
229 | }
230 | }
231 |
232 | private void setPreviewFocus(Camera camera){
233 | Camera.Parameters parameters = camera.getParameters();
234 | List focusList = parameters.getSupportedFocusModes();
235 | if(focusList.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)){
236 | parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
237 | }
238 | camera.setParameters(parameters);
239 | }
240 | }
241 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hyperai/hyperlpr_sdk_demo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.hyperai.hyperlpr_sdk_demo;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import androidx.core.app.ActivityCompat;
5 |
6 | import android.app.Activity;
7 | import android.content.Context;
8 | import android.content.Intent;
9 | import android.content.pm.PackageManager;
10 | import android.graphics.Bitmap;
11 | import android.graphics.BitmapFactory;
12 | import android.graphics.Color;
13 | import android.os.Bundle;
14 | import android.util.Log;
15 | import android.view.View;
16 | import android.widget.Button;
17 | import android.widget.ImageView;
18 | import android.widget.TextView;
19 |
20 | import com.bumptech.glide.Glide;
21 | import com.hyperai.hyperlpr3.HyperLPR3;
22 | import com.hyperai.hyperlpr3.bean.HyperLPRParameter;
23 | import com.hyperai.hyperlpr3.bean.Plate;
24 | import com.yuyh.library.imgsel.ISNav;
25 | import com.yuyh.library.imgsel.common.ImageLoader;
26 | import com.yuyh.library.imgsel.config.ISListConfig;
27 |
28 | import java.util.List;
29 |
30 |
31 | public class MainActivity extends AppCompatActivity {
32 |
33 | private Button cameraBtn;
34 | private Button albumBtn;
35 | private Context mCtx;
36 | private static final int REQUEST_LIST_CODE = 0;
37 | private static final int REQUEST_CAMERA_CODE = 1;
38 |
39 | private final String TAG = "HyperLPR-App";
40 |
41 | private ImageView imageView;
42 |
43 | private TextView mResult;
44 |
45 |
46 | private static final int REQUEST_EXTERNAL_STORAGE = 1;
47 | private static final String[] PERMISSIONS_STORAGE = {
48 | "android.permission.READ_EXTERNAL_STORAGE",
49 | "android.permission.WRITE_EXTERNAL_STORAGE",
50 | "android.permission.CAMERA"};
51 |
52 | public static void verifyStoragePermissions(Activity activity) {
53 |
54 | try {
55 | //检测是否有写的权限
56 | int permission = ActivityCompat.checkSelfPermission(activity,
57 | "android.permission.WRITE_EXTERNAL_STORAGE");
58 | ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE, REQUEST_EXTERNAL_STORAGE);
59 |
60 | if (permission != PackageManager.PERMISSION_GRANTED) {
61 | // 没有写的权限,去申请写的权限,会弹出对话框
62 | ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE, REQUEST_EXTERNAL_STORAGE);
63 | }
64 | } catch (Exception e) {
65 | e.printStackTrace();
66 | }
67 | }
68 |
69 | @Override
70 | protected void onCreate(Bundle savedInstanceState) {
71 | super.onCreate(savedInstanceState);
72 | setContentView(R.layout.activity_main);
73 | mCtx = this;
74 | cameraBtn = findViewById(R.id.cameraBtn);
75 | albumBtn = findViewById(R.id.albumBtn);
76 | imageView = findViewById(R.id.imageView);
77 | mResult = findViewById(R.id.mResult);
78 |
79 | verifyStoragePermissions(this);
80 |
81 |
82 | // 车牌识别算法配置参数
83 | HyperLPRParameter parameter = new HyperLPRParameter()
84 | .setDetLevel(HyperLPR3.DETECT_LEVEL_LOW)
85 | .setMaxNum(1)
86 | .setRecConfidenceThreshold(0.85f);
87 | // 初始化(仅执行一次生效)
88 | HyperLPR3.getInstance().init(this, parameter);
89 |
90 | ISNav.getInstance().init(new ImageLoader() {
91 | @Override
92 | public void displayImage(Context context, String path, ImageView imageView) {
93 | Glide.with(context).load(path).into(imageView);
94 | }
95 | });
96 |
97 | cameraBtn.setOnClickListener(new View.OnClickListener() {
98 | @Override
99 | public void onClick(View view) {
100 | Intent intent = new Intent(MainActivity.this, CameraActivity.class);
101 | MainActivity.this.startActivity(intent);
102 | }
103 | });
104 |
105 | albumBtn.setOnClickListener(new View.OnClickListener() {
106 | @Override
107 | public void onClick(View view) {
108 |
109 | // 自由配置选项
110 | ISListConfig config = new ISListConfig.Builder()
111 | // 是否多选, 默认true
112 | .multiSelect(false)
113 | // 是否记住上次选中记录, 仅当multiSelect为true的时候配置,默认为true
114 | .rememberSelected(false)
115 | // “确定”按钮背景色
116 | .btnBgColor(Color.GRAY)
117 | // “确定”按钮文字颜色
118 | .btnTextColor(Color.BLUE)
119 | // 使用沉浸式状态栏
120 | .statusBarColor(Color.parseColor("#3F51B5"))
121 | // 返回图标ResId
122 | .backResId(androidx.appcompat.R.drawable.abc_cab_background_top_mtrl_alpha)
123 | // 标题
124 | .title("图片")
125 | // 标题文字颜色
126 | .titleColor(Color.WHITE)
127 | // TitleBar背景色
128 | .titleBgColor(Color.parseColor("#3F51B5"))
129 | // 裁剪大小。needCrop为true的时候配置
130 | .cropSize(1, 1, 200, 200)
131 | .needCrop(false)
132 | // 第一个是否显示相机,默认true
133 | .needCamera(false)
134 | // 最大选择图片数量,默认9
135 | .maxNum(1)
136 | .build();
137 |
138 | // 跳转到图片选择器
139 | ISNav.getInstance().toListActivity(mCtx, config, REQUEST_LIST_CODE);
140 | }
141 | });
142 |
143 | }
144 |
145 |
146 | @Override
147 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
148 | super.onActivityResult(requestCode, resultCode, data);
149 | Bitmap bitmap = null;
150 | String showText = "";
151 | // 图片选择结果回调
152 | if (requestCode == REQUEST_LIST_CODE && resultCode == RESULT_OK && data != null) {
153 | List pathList = data.getStringArrayListExtra("result");
154 | Log.i(TAG, pathList.get(0));
155 | bitmap = BitmapFactory.decodeFile(pathList.get(0));
156 | } else if (requestCode == REQUEST_CAMERA_CODE && resultCode == RESULT_OK && data != null) {
157 | String path = data.getStringExtra("result");
158 | Log.i(TAG, path);
159 | bitmap = BitmapFactory.decodeFile(path);
160 | }
161 | if (bitmap != null) {
162 |
163 | imageView.setImageBitmap(bitmap);
164 | Plate[] plates = HyperLPR3.getInstance().plateRecognition(bitmap, HyperLPR3.CAMERA_ROTATION_0, HyperLPR3.STREAM_BGRA);
165 | for (Plate plate: plates) {
166 | String type = "未知车牌";
167 | if (plate.getType() != HyperLPR3.PLATE_TYPE_UNKNOWN) {
168 | type = HyperLPR3.PLATE_TYPE_MAPS[plate.getType()];
169 | }
170 | String pStr = "[" + type + "]" + plate.getCode() + "\n";
171 | showText += pStr;
172 | mResult.setText(showText);
173 |
174 | }
175 | }
176 | }
177 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_camera.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
20 |
21 |
32 |
33 |
43 |
44 |
56 |
57 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/app/src/main/res/mipmap-xxhdpi/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | HyperLPR3-App
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/app/src/test/java/com/hyperai/hyperlpr_sdk_demo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.hyperai.hyperlpr_sdk_demo;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | repositories {
4 | google()
5 | mavenCentral()
6 | }
7 | dependencies {
8 | classpath "com.android.tools.build:gradle:7.0.2"
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | task clean(type: Delete) {
16 | delete rootProject.buildDir
17 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jan 27 02:05:45 CST 2023
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/hyperlpr3/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/hyperlpr3/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'maven-publish'
4 | }
5 |
6 | android {
7 | compileSdk 28
8 |
9 | defaultConfig {
10 | minSdk 21
11 | targetSdk 28
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16 | consumerProguardFiles "consumer-rules.pro"
17 |
18 | ndk { abiFilters "armeabi-v7a", "arm64-v8a" }
19 | }
20 |
21 | buildTypes {
22 | release {
23 | minifyEnabled false
24 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
25 | }
26 | }
27 |
28 | sourceSets {
29 | main {
30 | jniLibs.srcDirs = ['libs']
31 | assets.srcDirs = ['src/main/assets']
32 | }
33 | }
34 |
35 | compileOptions {
36 | sourceCompatibility JavaVersion.VERSION_1_8
37 | targetCompatibility JavaVersion.VERSION_1_8
38 | }
39 | }
40 |
41 | dependencies {
42 |
43 | implementation 'androidx.appcompat:appcompat:1.2.0'
44 | implementation 'com.google.android.material:material:1.3.0'
45 | testImplementation 'junit:junit:4.+'
46 | androidTestImplementation 'androidx.test.ext:junit:1.1.2'
47 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
48 |
49 | }
50 |
51 | afterEvaluate {
52 | // 官方建议使用上传方法
53 | publishing {
54 | publications {
55 | // Creates a Maven publication called "release".
56 | release(MavenPublication) {
57 | from components.release // 表示发布 release(jitpack 都不会使用到)
58 | groupId = 'com.github.tunmx' //groupId 随便取 , 这个是依赖库的组 id
59 | artifactId = 'hyperlpr3-android-sdk' //artifactId 随便取 , 依赖库的名称(jitpack 都不会使用到)
60 | version = '1.0.3' // 当前版本依赖库版本号,这个jitpack不会使用到,只是我们开发者自己查看
61 | }
62 | }
63 | }
64 | }
--------------------------------------------------------------------------------
/hyperlpr3/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/hyperlpr3/consumer-rules.pro
--------------------------------------------------------------------------------
/hyperlpr3/libs/arm64-v8a/libhyperlpr3.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/hyperlpr3/libs/arm64-v8a/libhyperlpr3.so
--------------------------------------------------------------------------------
/hyperlpr3/libs/armeabi-v7a/libhyperlpr3.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/hyperlpr3/libs/armeabi-v7a/libhyperlpr3.so
--------------------------------------------------------------------------------
/hyperlpr3/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/hyperlpr3/src/androidTest/java/com/hyperai/hyperlpr3/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.hyperai.hyperlpr3;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 | assertEquals("com.hyperai.hyperlpr3.test", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/hyperlpr3/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
--------------------------------------------------------------------------------
/hyperlpr3/src/main/assets/r2_mobile/b320_backbone_h.mnn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/hyperlpr3/src/main/assets/r2_mobile/b320_backbone_h.mnn
--------------------------------------------------------------------------------
/hyperlpr3/src/main/assets/r2_mobile/b320_header_h.mnn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/hyperlpr3/src/main/assets/r2_mobile/b320_header_h.mnn
--------------------------------------------------------------------------------
/hyperlpr3/src/main/assets/r2_mobile/b640x_backbone_h.mnn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/hyperlpr3/src/main/assets/r2_mobile/b640x_backbone_h.mnn
--------------------------------------------------------------------------------
/hyperlpr3/src/main/assets/r2_mobile/b640x_head_h.mnn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/hyperlpr3/src/main/assets/r2_mobile/b640x_head_h.mnn
--------------------------------------------------------------------------------
/hyperlpr3/src/main/assets/r2_mobile/litemodel_cls_96xh.mnn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/hyperlpr3/src/main/assets/r2_mobile/litemodel_cls_96xh.mnn
--------------------------------------------------------------------------------
/hyperlpr3/src/main/assets/r2_mobile/rpv3_mdict_160h.mnn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HyperInspire/hyperlpr3-android-sdk/7e084ddefbfbeab12d7591123fc57b05ac45d89c/hyperlpr3/src/main/assets/r2_mobile/rpv3_mdict_160h.mnn
--------------------------------------------------------------------------------
/hyperlpr3/src/main/java/com/hyperai/hyperlpr3/HyperLPR3.java:
--------------------------------------------------------------------------------
1 | package com.hyperai.hyperlpr3;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.util.Log;
6 |
7 | import com.hyperai.hyperlpr3.api.APIDefine;
8 | import com.hyperai.hyperlpr3.bean.HyperLPRParameter;
9 | import com.hyperai.hyperlpr3.bean.Plate;
10 | import com.hyperai.hyperlpr3.core.HyperLPRCore;
11 | import com.hyperai.hyperlpr3.settings.TypeDefine;
12 | import com.hyperai.hyperlpr3.settings.SDKConfig;
13 | import com.hyperai.hyperlpr3.utils.SDKUtils;
14 |
15 | public class HyperLPR3 extends TypeDefine implements APIDefine {
16 |
17 | private final String TAG = "HyperLPR3-SDK";
18 |
19 | private final HyperLPRCore mCore;
20 |
21 | private boolean isInitSuccess;
22 |
23 | private HyperLPR3() {
24 | mCore = new HyperLPRCore();
25 | isInitSuccess = false;
26 | }
27 |
28 | private static class LazyHolder {
29 | private static final HyperLPR3 INSTANCE = new HyperLPR3();
30 | }
31 |
32 | public static final HyperLPR3 getInstance() {
33 | return LazyHolder.INSTANCE;
34 | }
35 |
36 |
37 | public void release() {
38 | mCore.release();
39 | }
40 |
41 | @Override
42 | protected void finalize() throws Throwable {
43 | super.finalize();
44 | release();
45 | }
46 |
47 | /**
48 | * Initialize the license plate recognition algorithm SDK
49 | *
50 | * @param context context
51 | * @param parameter Initialization parameter
52 | */
53 | @Override
54 | public void init(Context context, HyperLPRParameter parameter) {
55 | if (!isInitSuccess) {
56 | String mResourceFolderPath = context.getExternalFilesDir(null).getAbsolutePath() + "/";
57 | SDKUtils.copyFilesFromAssets(context, SDKConfig.packDirName, mResourceFolderPath);
58 | Log.i(TAG, "resource: " + mResourceFolderPath);
59 | if (parameter.getModelPath() == null || "".equals(parameter.getModelPath())) {
60 | parameter.setModelPath(mResourceFolderPath);
61 | }
62 | mCore.createRecognizerContext(parameter);
63 | isInitSuccess = true;
64 | }
65 | }
66 |
67 | /**
68 | * License plate recognition interface.
69 | *
70 | * @param buf Image data buffer.
71 | * @param height Height of the image
72 | * @param width Width of the image
73 | * @param rotation Original data buffer rotation Angle
74 | * @param format Buffer data coded format
75 | * @return Resulting object array
76 | */
77 | @Override
78 | public Plate[] plateRecognition(byte[] buf, int height, int width, int rotation, int format) {
79 | if (!isInitSuccess) {
80 | Log.e(TAG, "HyperLPR3 is uninitialized.");
81 | return new Plate[0];
82 | }
83 | return mCore.plateRecognitionFromBuffer(buf, height, width, rotation, format);
84 | }
85 |
86 | /**
87 | * License plate recognition interface.
88 | *
89 | * @param image Bitmap image
90 | * @param rotation Original data buffer rotation Angle
91 | * @param format Buffer data coded format
92 | * @return Resulting object array
93 | */
94 | @Override
95 | public Plate[] plateRecognition(Bitmap image, int rotation, int format) {
96 | if (!isInitSuccess) {
97 | Log.e(TAG, "HyperLPR3 is uninitialized.");
98 | return new Plate[0];
99 | }
100 | int mWidth = image.getWidth();
101 | int mHeight = image.getHeight();
102 | int[] data = new int[image.getWidth() * image.getHeight()];
103 | image.getPixels(data, 0, mWidth, 0, 0, mWidth, mHeight);
104 | return mCore.plateRecognitionFromImage(data, mHeight, mWidth, rotation, format);
105 | }
106 |
107 |
108 | }
109 |
--------------------------------------------------------------------------------
/hyperlpr3/src/main/java/com/hyperai/hyperlpr3/api/APIDefine.java:
--------------------------------------------------------------------------------
1 | package com.hyperai.hyperlpr3.api;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 |
6 | import com.hyperai.hyperlpr3.bean.HyperLPRParameter;
7 | import com.hyperai.hyperlpr3.bean.Plate;
8 |
9 | public interface APIDefine {
10 |
11 | /**
12 | * Initialize the license plate recognition algorithm SDK
13 | *
14 | * @param context context
15 | * @param parameter Initialization parameter
16 | * */
17 | void init(Context context, HyperLPRParameter parameter);
18 |
19 | /**
20 | * License plate recognition interface.
21 | *
22 | * @param buf Image data buffer.
23 | * @param height Height of the image
24 | * @param width Width of the image
25 | * @param rotation Original data buffer rotation Angle
26 | * @param format Buffer data coded format
27 | * @return Resulting object array
28 | */
29 | Plate[] plateRecognition(byte[] buf, int height, int width, int rotation, int format);
30 |
31 | /**
32 | * License plate recognition interface.
33 | *
34 | * @param image Bitmap image
35 | * @param rotation Original data buffer rotation Angle
36 | * @param format Buffer data coded format
37 | * @return Resulting object array
38 | */
39 | Plate[] plateRecognition(Bitmap image, int rotation, int format);
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/hyperlpr3/src/main/java/com/hyperai/hyperlpr3/bean/HyperLPRParameter.java:
--------------------------------------------------------------------------------
1 | package com.hyperai.hyperlpr3.bean;
2 |
3 | import com.hyperai.hyperlpr3.settings.TypeDefine;
4 |
5 | public class HyperLPRParameter {
6 |
7 | private String modelPath;
8 |
9 | private int threads = 1;
10 |
11 | private boolean useHalf = true;
12 |
13 | private float boxConfThreshold = 0.25f;
14 |
15 | private float nmsThreshold = 0.6f;
16 |
17 | private float recConfidenceThreshold = 0.85f;
18 |
19 | private int detLevel = TypeDefine.DETECT_LEVEL_LOW;
20 |
21 | private int maxNum = 3;
22 |
23 | public HyperLPRParameter() {
24 | }
25 |
26 | public int getMaxNum() {
27 | return maxNum;
28 | }
29 |
30 | public HyperLPRParameter setMaxNum(int maxNum) {
31 | this.maxNum = maxNum;
32 | return this;
33 | }
34 |
35 | public String getModelPath() {
36 | return modelPath;
37 | }
38 |
39 | public HyperLPRParameter setModelPath(String modelPath) {
40 | this.modelPath = modelPath;
41 | return this;
42 | }
43 |
44 | public int getThreads() {
45 | return threads;
46 | }
47 |
48 | public HyperLPRParameter setThreads(int threads) {
49 | this.threads = threads;
50 | return this;
51 | }
52 |
53 | public boolean isUseHalf() {
54 | return useHalf;
55 | }
56 |
57 | public HyperLPRParameter setUseHalf(boolean useHalf) {
58 | this.useHalf = useHalf;
59 | return this;
60 | }
61 |
62 | public float getBoxConfThreshold() {
63 | return boxConfThreshold;
64 | }
65 |
66 | public HyperLPRParameter setBoxConfThreshold(float boxConfThreshold) {
67 | this.boxConfThreshold = boxConfThreshold;
68 | return this;
69 | }
70 |
71 | public float getNmsThreshold() {
72 | return nmsThreshold;
73 | }
74 |
75 | public HyperLPRParameter setNmsThreshold(float nmsThreshold) {
76 | this.nmsThreshold = nmsThreshold;
77 | return this;
78 | }
79 |
80 | public float getRecConfidenceThreshold() {
81 | return recConfidenceThreshold;
82 | }
83 |
84 | public HyperLPRParameter setRecConfidenceThreshold(float recConfidenceThreshold) {
85 | this.recConfidenceThreshold = recConfidenceThreshold;
86 | return this;
87 | }
88 |
89 | public int getDetLevel() {
90 | return detLevel;
91 | }
92 |
93 | public HyperLPRParameter setDetLevel(int detLevel) {
94 | this.detLevel = detLevel;
95 | return this;
96 | }
97 |
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/hyperlpr3/src/main/java/com/hyperai/hyperlpr3/bean/Plate.java:
--------------------------------------------------------------------------------
1 | package com.hyperai.hyperlpr3.bean;
2 |
3 | public class Plate {
4 |
5 | private float x1;
6 |
7 | private float y1;
8 |
9 | private float x2;
10 |
11 | private float y2;
12 |
13 | private int type;
14 |
15 | private float confidence;
16 |
17 | private String code;
18 |
19 | public Plate() {};
20 |
21 | public float getX1() {
22 | return x1;
23 | }
24 |
25 | public void setX1(float x1) {
26 | this.x1 = x1;
27 | }
28 |
29 | public float getY1() {
30 | return y1;
31 | }
32 |
33 | public void setY1(float y1) {
34 | this.y1 = y1;
35 | }
36 |
37 | public float getX2() {
38 | return x2;
39 | }
40 |
41 | public void setX2(float x2) {
42 | this.x2 = x2;
43 | }
44 |
45 | public float getY2() {
46 | return y2;
47 | }
48 |
49 | public void setY2(float y2) {
50 | this.y2 = y2;
51 | }
52 |
53 | public int getType() {
54 | return type;
55 | }
56 |
57 | public void setType(int type) {
58 | this.type = type;
59 | }
60 |
61 | public float getConfidence() {
62 | return confidence;
63 | }
64 |
65 | public void setConfidence(float confidence) {
66 | this.confidence = confidence;
67 | }
68 |
69 | public String getCode() {
70 | return code;
71 | }
72 |
73 | public void setCode(String code) {
74 | this.code = code;
75 | }
76 |
77 | @Override
78 | public String toString() {
79 | return "Plate{" +
80 | "x1=" + x1 +
81 | ", y1=" + y1 +
82 | ", x2=" + x2 +
83 | ", y2=" + y2 +
84 | ", type=" + type +
85 | ", confidence=" + confidence +
86 | ", code='" + code + '\'' +
87 | '}';
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/hyperlpr3/src/main/java/com/hyperai/hyperlpr3/core/HyperLPRCore.java:
--------------------------------------------------------------------------------
1 | package com.hyperai.hyperlpr3.core;
2 |
3 | import android.util.Log;
4 |
5 | import com.hyperai.hyperlpr3.bean.HyperLPRParameter;
6 | import com.hyperai.hyperlpr3.bean.Plate;
7 |
8 | public class HyperLPRCore {
9 |
10 | final String TAG = "HyperLPRCore";
11 |
12 | static {
13 | System.loadLibrary("hyperlpr3");
14 | }
15 |
16 | private long ctxHandle_;
17 |
18 | private boolean isRunning_;
19 |
20 | public void createRecognizerContext(HyperLPRParameter parameter) {
21 | ctxHandle_ = CreateRecognizerContext(parameter);
22 | Log.i(TAG, "HANDLE: " + ctxHandle_);
23 | isRunning_ = true;
24 | }
25 |
26 | public Plate[] plateRecognitionFromBuffer(byte[] buf, int height, int width, int rotation, int format) {
27 | return PlateRecognitionFromBuffer(ctxHandle_, buf, height, width, rotation, format);
28 | }
29 |
30 | public Plate[] plateRecognitionFromImage(int[] buf, int height, int width, int rotation, int format) {
31 | return PlateRecognitionFromImage(ctxHandle_, buf, height, width, rotation, format);
32 | }
33 |
34 | public int release() {
35 | int ret = -1;
36 | if (isRunning_) {
37 | ret = ReleaseRecognizerContext(ctxHandle_);
38 | isRunning_ = false;
39 | ctxHandle_ = 0;
40 | }
41 | return ret;
42 | }
43 |
44 | // ===================Native==================
45 |
46 | // native void TestBuffer(String savePath, byte[] buf, int height, int width, int rotation);
47 |
48 | native long CreateRecognizerContext(HyperLPRParameter parameterObj);
49 |
50 | native int ReleaseRecognizerContext(long handle);
51 |
52 | native Plate[] PlateRecognitionFromBuffer(long handle, byte[] buf, int height, int width, int rotation, int format);
53 |
54 | native Plate[] PlateRecognitionFromImage(long handle, int[] buf, int height, int width, int rotation, int format);
55 |
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/hyperlpr3/src/main/java/com/hyperai/hyperlpr3/settings/SDKConfig.java:
--------------------------------------------------------------------------------
1 | package com.hyperai.hyperlpr3.settings;
2 |
3 | public class SDKConfig {
4 |
5 | public static final String packDirName = "r2_mobile";
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/hyperlpr3/src/main/java/com/hyperai/hyperlpr3/settings/TypeDefine.java:
--------------------------------------------------------------------------------
1 | package com.hyperai.hyperlpr3.settings;
2 |
3 | public class TypeDefine {
4 |
5 | /** 四种情况的转角 */
6 | public static final int CAMERA_ROTATION_0 = 0;
7 | public static final int CAMERA_ROTATION_90 = 1;
8 | public static final int CAMERA_ROTATION_180 = 2;
9 | public static final int CAMERA_ROTATION_270 = 3;
10 |
11 | /** 低开销检测模式 */
12 | public static final int DETECT_LEVEL_LOW = 0;
13 | /** 高开销检测模式 */
14 | public static final int DETECT_LEVEL_HIGH = 1;
15 |
16 | /** Image in RGB format - RGB排列格式的图像 */
17 | public static final int STREAM_RGB = 0;
18 | /** Image in BGR format (Opencv Mat default) - BGR排列格式的图像(OpenCV的Mat默认) */
19 | public static final int STREAM_BGR = 1;
20 | /** Image in RGB with alpha channel format -带alpha通道的RGB排列格式的图像 */
21 | public static final int STREAM_RGBA = 2;
22 | /** Image in BGR with alpha channel format -带alpha通道的BGR排列格式的图像 */
23 | public static final int STREAM_BGRA = 3;
24 | /** Image in YUV NV12 format - YUV NV12排列的图像格式 */
25 | public static final int STREAM_YUV_NV12 = 4;
26 | /** Image in YUV NV21 format - YUV NV21排列的图像格式 */
27 | public static final int STREAM_YUV_NV21 = 5;
28 |
29 |
30 | /** 未知车牌 */
31 | public static final int PLATE_TYPE_UNKNOWN = -1;
32 | /** 蓝牌 */
33 | public static final int PLATE_TYPE_BLUE = 0;
34 | /** 黄牌单层 */
35 | public static final int PLATE_TYPE_YELLOW_SINGLE = 1;
36 | /** 白牌单层 */
37 | public static final int PLATE_TYPE_WHILE_SINGLE = 2;
38 | /** 绿牌新能源 */
39 | public static final int PLATE_TYPE_GREEN = 3;
40 | /** 黑牌港澳 */
41 | public static final int PLATE_TYPE_BLACK_HK_MACAO = 4;
42 | /** 香港单层 */
43 | public static final int PLATE_TYPE_HK_SINGLE = 5;
44 | /** 香港双层 */
45 | public static final int PLATE_TYPE_HK_DOUBLE = 6;
46 | /** 澳门单层 */
47 | public static final int PLATE_TYPE_MACAO_SINGLE = 7;
48 | /** 澳门双层 */
49 | public static final int PLATE_TYPE_MACAO_DOUBLE = 8;
50 | /** 黄牌双层 */
51 | public static final int PLATE_TYPE_YELLOW_DOUBLE = 9;
52 |
53 | public static final String[] PLATE_TYPE_MAPS = {"蓝牌", "黄牌单层", "白牌单层", "绿牌新能源", "黑牌港澳", "香港单层", "香港双层", "澳门单层", "澳门双层", "黄牌双层"};
54 | }
55 |
--------------------------------------------------------------------------------
/hyperlpr3/src/main/java/com/hyperai/hyperlpr3/utils/SDKUtils.java:
--------------------------------------------------------------------------------
1 | package com.hyperai.hyperlpr3.utils;
2 |
3 | import android.content.Context;
4 | import android.content.res.AssetManager;
5 | import android.graphics.Bitmap;
6 | import android.graphics.BitmapFactory;
7 | import android.graphics.Canvas;
8 | import android.graphics.DashPathEffect;
9 | import android.graphics.Matrix;
10 | import android.graphics.Paint;
11 | import android.graphics.Path;
12 | import android.util.Log;
13 |
14 | import java.io.File;
15 | import java.io.FileOutputStream;
16 | import java.io.IOException;
17 | import java.io.InputStream;
18 |
19 | public class SDKUtils {
20 | static public void copyFilesFromAssets(Context context, String oldPath, String newPath) {
21 | try {
22 | String[] fileNames = context.getAssets().list(oldPath);
23 | if (fileNames.length > 0) {
24 | // directory
25 | File file = new File(newPath);
26 | if (!file.mkdir()) {
27 | Log.d("mkdir", "can't make folder");
28 | }
29 | // return false; // copy recursively
30 | for (String fileName : fileNames) {
31 | copyFilesFromAssets(context, oldPath + "/" + fileName,
32 | newPath + "/" + fileName);
33 | }
34 | } else {
35 | // file
36 | InputStream is = context.getAssets().open(oldPath);
37 | FileOutputStream fos = new FileOutputStream(new File(newPath));
38 | byte[] buffer = new byte[1024];
39 | int byteCount;
40 | while ((byteCount = is.read(buffer)) != -1) {
41 | fos.write(buffer, 0, byteCount);
42 | }
43 | fos.flush();
44 | is.close();
45 | fos.close();
46 | }
47 | } catch (Exception e) {
48 | // TODO Auto-generated catch block
49 | e.printStackTrace();
50 | }
51 | }
52 |
53 | static public void mkdirsFeaturesAssets(Context context, String path, String images, String features) {
54 | try {
55 | File file = new File(path);
56 | File imagePath = new File(path + images);
57 | File featurePath = new File(path + features);
58 | if (!file.mkdir()) {
59 | Log.d("mkdir", "can't make folder: " + file);
60 | }
61 | if (!imagePath.mkdir()) {
62 | Log.d("mkdir", "can't make folder: " + imagePath);
63 | }
64 | if (!featurePath.mkdir()) {
65 | Log.d("mkdir", "can't make folder: " + featurePath);
66 | }
67 | } catch (Exception e) {
68 | // TODO Auto-generated catch block
69 | e.printStackTrace();
70 | }
71 | }
72 |
73 | static public String saveBitmap(String savePath, String name, Bitmap bitmap) throws IOException {
74 | File f = new File(savePath, name + ".png");
75 | if (f.exists()) {
76 | f.delete();
77 | }
78 | FileOutputStream out = new FileOutputStream(f);
79 | bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
80 | out.flush();
81 | out.close();
82 | return f.getAbsolutePath();
83 | }
84 |
85 |
86 | static public boolean cropperBitmap(Bitmap bitmap, int[] rePoints, String sdcardPath, String name) {
87 | int newWidth = 160;
88 | int newHeight = 192;
89 | float scaleWidth = ((float) newWidth) / bitmap.getWidth();
90 | float scaleHeight = ((float) newHeight) / bitmap.getHeight();
91 | Matrix matrix = new Matrix();
92 | // matrix.postTranslate()
93 | matrix.postScale(scaleWidth, scaleHeight);
94 | matrix.setScale(-1, 1);
95 | int px = Math.max(0, rePoints[0]);
96 | int py = Math.max(0, rePoints[1]);
97 | int w = rePoints[2] - px;
98 | int h = rePoints[3] - py;
99 | int pw = (bitmap.getWidth() - w > 0) ? w - 1 : bitmap.getWidth() - 1;
100 | int ph = (bitmap.getHeight() - h > 0) ? h - 1 : bitmap.getHeight() - 1;
101 | try {
102 | Bitmap crop = Bitmap.createBitmap(bitmap, px, py, pw, ph, matrix, true);
103 | // String sdcardPath = Environment.getExternalStorageDirectory() + File.separator + Const.root + Const.save + Const.images;
104 | saveBitmap(sdcardPath, name, crop);
105 | } catch (Exception err) {
106 | Log.d("crop", "ext");
107 | return false;
108 | }
109 | return true;
110 | }
111 |
112 |
113 | public static Bitmap getImageFromAssetsFile(Context context, String fileName) {
114 | Bitmap image = null;
115 | AssetManager am = context.getResources().getAssets();
116 | try {
117 | InputStream is = am.open(fileName);
118 | image = BitmapFactory.decodeStream(is);
119 | is.close();
120 | } catch (IOException e) {
121 | e.printStackTrace();
122 | }
123 |
124 | return image;
125 | }
126 |
127 |
128 |
129 | }
130 |
--------------------------------------------------------------------------------
/hyperlpr3/src/test/java/com/hyperai/hyperlpr3/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.hyperai.hyperlpr3;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | dependencyResolutionManagement {
2 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
3 | repositories {
4 | google()
5 | mavenCentral()
6 | jcenter() // Warning: this repository is going to shut down soon
7 | maven { url "https://jitpack.io" }
8 | }
9 | }
10 | rootProject.name = "HyperLPR_SDK_Demo"
11 | include ':app'
12 | include ':hyperlpr3'
13 |
--------------------------------------------------------------------------------