Update Android Demo
parent
89372089b2
commit
a9f0665187
@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
@ -1,15 +0,0 @@
|
||||
## HyperLPR3-Android-SDK HyperLPR3-License Plate Recognition Android SDK
|
||||
|
||||
[中文文档](README_CH.md)
|
||||
|
||||
### Source Code Project
|
||||
|
||||
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).
|
||||
|
||||
### Supporting Platform
|
||||
|
||||
- Android: arm64-v8a、armeabi-v7a
|
||||
|
||||
### How to Use
|
||||
|
||||
TODO
|
@ -1,13 +0,0 @@
|
||||
## HyperLPR3-Android-SDK HyperLPR3-车牌识别安卓SDK
|
||||
|
||||
### 源码工程
|
||||
|
||||
需要了解编译相关源码可移步到[HyperLPR工程](https://github.com/szad670401/HyperLPR)。
|
||||
|
||||
### 支持平台
|
||||
|
||||
- Android: arm64-v8a、armeabi-v7a
|
||||
|
||||
### 如何使用
|
||||
|
||||
TODO
|
Binary file not shown.
@ -1,20 +0,0 @@
|
||||
{
|
||||
"version": 3,
|
||||
"artifactType": {
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "com.hyperai.hyperlpr_sdk_demo",
|
||||
"variantName": "release",
|
||||
"elements": [
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 1,
|
||||
"versionName": "1.0",
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
],
|
||||
"elementType": "File"
|
||||
}
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
@ -1,3 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">HyperLPR3-App</string>
|
||||
<string name="app_name">HyperLPR3-Example</string>
|
||||
</resources>
|
@ -1,4 +1,4 @@
|
||||
package com.hyperai.hyperlpr3;
|
||||
package com.hyperai.example.lpr3_demo;
|
||||
|
||||
import org.junit.Test;
|
||||
|
@ -1,17 +0,0 @@
|
||||
package com.hyperai.hyperlpr_sdk_demo;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
/build
|
@ -1,21 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
@ -1,26 +0,0 @@
|
||||
package com.hyperai.hyperlpr3;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("com.hyperai.hyperlpr3.test", appContext.getPackageName());
|
||||
}
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.hyperai.hyperlpr3">
|
||||
|
||||
</manifest>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,108 +0,0 @@
|
||||
package com.hyperai.hyperlpr3;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.Log;
|
||||
|
||||
import com.hyperai.hyperlpr3.api.APIDefine;
|
||||
import com.hyperai.hyperlpr3.bean.HyperLPRParameter;
|
||||
import com.hyperai.hyperlpr3.bean.Plate;
|
||||
import com.hyperai.hyperlpr3.core.HyperLPRCore;
|
||||
import com.hyperai.hyperlpr3.settings.TypeDefine;
|
||||
import com.hyperai.hyperlpr3.settings.SDKConfig;
|
||||
import com.hyperai.hyperlpr3.utils.SDKUtils;
|
||||
|
||||
public class HyperLPR3 extends TypeDefine implements APIDefine {
|
||||
|
||||
private final String TAG = "HyperLPR3-SDK";
|
||||
|
||||
private final HyperLPRCore mCore;
|
||||
|
||||
private boolean isInitSuccess;
|
||||
|
||||
private HyperLPR3() {
|
||||
mCore = new HyperLPRCore();
|
||||
isInitSuccess = false;
|
||||
}
|
||||
|
||||
private static class LazyHolder {
|
||||
private static final HyperLPR3 INSTANCE = new HyperLPR3();
|
||||
}
|
||||
|
||||
public static final HyperLPR3 getInstance() {
|
||||
return LazyHolder.INSTANCE;
|
||||
}
|
||||
|
||||
|
||||
public void release() {
|
||||
mCore.release();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
super.finalize();
|
||||
release();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the license plate recognition algorithm SDK
|
||||
*
|
||||
* @param context context
|
||||
* @param parameter Initialization parameter
|
||||
*/
|
||||
@Override
|
||||
public void init(Context context, HyperLPRParameter parameter) {
|
||||
if (!isInitSuccess) {
|
||||
String mResourceFolderPath = context.getExternalFilesDir(null).getAbsolutePath() + "/";
|
||||
SDKUtils.copyFilesFromAssets(context, SDKConfig.packDirName, mResourceFolderPath);
|
||||
Log.i(TAG, "resource: " + mResourceFolderPath);
|
||||
if (parameter.getModelPath() == null || "".equals(parameter.getModelPath())) {
|
||||
parameter.setModelPath(mResourceFolderPath);
|
||||
}
|
||||
mCore.createRecognizerContext(parameter);
|
||||
isInitSuccess = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* License plate recognition interface.
|
||||
*
|
||||
* @param buf Image data buffer.
|
||||
* @param height Height of the image
|
||||
* @param width Width of the image
|
||||
* @param rotation Original data buffer rotation Angle
|
||||
* @param format Buffer data coded format
|
||||
* @return Resulting object array
|
||||
*/
|
||||
@Override
|
||||
public Plate[] plateRecognition(byte[] buf, int height, int width, int rotation, int format) {
|
||||
if (!isInitSuccess) {
|
||||
Log.e(TAG, "HyperLPR3 is uninitialized.");
|
||||
return new Plate[0];
|
||||
}
|
||||
return mCore.plateRecognitionFromBuffer(buf, height, width, rotation, format);
|
||||
}
|
||||
|
||||
/**
|
||||
* License plate recognition interface.
|
||||
*
|
||||
* @param image Bitmap image
|
||||
* @param rotation Original data buffer rotation Angle
|
||||
* @param format Buffer data coded format
|
||||
* @return Resulting object array
|
||||
*/
|
||||
@Override
|
||||
public Plate[] plateRecognition(Bitmap image, int rotation, int format) {
|
||||
if (!isInitSuccess) {
|
||||
Log.e(TAG, "HyperLPR3 is uninitialized.");
|
||||
return new Plate[0];
|
||||
}
|
||||
int mWidth = image.getWidth();
|
||||
int mHeight = image.getHeight();
|
||||
int[] data = new int[image.getWidth() * image.getHeight()];
|
||||
image.getPixels(data, 0, mWidth, 0, 0, mWidth, mHeight);
|
||||
return mCore.plateRecognitionFromImage(data, mHeight, mWidth, rotation, format);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package com.hyperai.hyperlpr3.api;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import com.hyperai.hyperlpr3.bean.HyperLPRParameter;
|
||||
import com.hyperai.hyperlpr3.bean.Plate;
|
||||
|
||||
public interface APIDefine {
|
||||
|
||||
/**
|
||||
* Initialize the license plate recognition algorithm SDK
|
||||
*
|
||||
* @param context context
|
||||
* @param parameter Initialization parameter
|
||||
* */
|
||||
void init(Context context, HyperLPRParameter parameter);
|
||||
|
||||
/**
|
||||
* License plate recognition interface.
|
||||
*
|
||||
* @param buf Image data buffer.
|
||||
* @param height Height of the image
|
||||
* @param width Width of the image
|
||||
* @param rotation Original data buffer rotation Angle
|
||||
* @param format Buffer data coded format
|
||||
* @return Resulting object array
|
||||
*/
|
||||
Plate[] plateRecognition(byte[] buf, int height, int width, int rotation, int format);
|
||||
|
||||
/**
|
||||
* License plate recognition interface.
|
||||
*
|
||||
* @param image Bitmap image
|
||||
* @param rotation Original data buffer rotation Angle
|
||||
* @param format Buffer data coded format
|
||||
* @return Resulting object array
|
||||
*/
|
||||
Plate[] plateRecognition(Bitmap image, int rotation, int format);
|
||||
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
package com.hyperai.hyperlpr3.bean;
|
||||
|
||||
import com.hyperai.hyperlpr3.settings.TypeDefine;
|
||||
|
||||
public class HyperLPRParameter {
|
||||
|
||||
private String modelPath;
|
||||
|
||||
private int threads = 1;
|
||||
|
||||
private boolean useHalf = true;
|
||||
|
||||
private float boxConfThreshold = 0.25f;
|
||||
|
||||
private float nmsThreshold = 0.6f;
|
||||
|
||||
private float recConfidenceThreshold = 0.85f;
|
||||
|
||||
private int detLevel = TypeDefine.DETECT_LEVEL_LOW;
|
||||
|
||||
private int maxNum = 3;
|
||||
|
||||
public HyperLPRParameter() {
|
||||
}
|
||||
|
||||
public int getMaxNum() {
|
||||
return maxNum;
|
||||
}
|
||||
|
||||
public HyperLPRParameter setMaxNum(int maxNum) {
|
||||
this.maxNum = maxNum;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getModelPath() {
|
||||
return modelPath;
|
||||
}
|
||||
|
||||
public HyperLPRParameter setModelPath(String modelPath) {
|
||||
this.modelPath = modelPath;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getThreads() {
|
||||
return threads;
|
||||
}
|
||||
|
||||
public HyperLPRParameter setThreads(int threads) {
|
||||
this.threads = threads;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isUseHalf() {
|
||||
return useHalf;
|
||||
}
|
||||
|
||||
public HyperLPRParameter setUseHalf(boolean useHalf) {
|
||||
this.useHalf = useHalf;
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getBoxConfThreshold() {
|
||||
return boxConfThreshold;
|
||||
}
|
||||
|
||||
public HyperLPRParameter setBoxConfThreshold(float boxConfThreshold) {
|
||||
this.boxConfThreshold = boxConfThreshold;
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getNmsThreshold() {
|
||||
return nmsThreshold;
|
||||
}
|
||||
|
||||
public HyperLPRParameter setNmsThreshold(float nmsThreshold) {
|
||||
this.nmsThreshold = nmsThreshold;
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getRecConfidenceThreshold() {
|
||||
return recConfidenceThreshold;
|
||||
}
|
||||
|
||||
public HyperLPRParameter setRecConfidenceThreshold(float recConfidenceThreshold) {
|
||||
this.recConfidenceThreshold = recConfidenceThreshold;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getDetLevel() {
|
||||
return detLevel;
|
||||
}
|
||||
|
||||
public HyperLPRParameter setDetLevel(int detLevel) {
|
||||
this.detLevel = detLevel;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
package com.hyperai.hyperlpr3.bean;
|
||||
|
||||
public class Plate {
|
||||
|
||||
private float x1;
|
||||
|
||||
private float y1;
|
||||
|
||||
private float x2;
|
||||
|
||||
private float y2;
|
||||
|
||||
private int type;
|
||||
|
||||
private float confidence;
|
||||
|
||||
private String code;
|
||||
|
||||
public Plate() {};
|
||||
|
||||
public float getX1() {
|
||||
return x1;
|
||||
}
|
||||
|
||||
public void setX1(float x1) {
|
||||
this.x1 = x1;
|
||||
}
|
||||
|
||||
public float getY1() {
|
||||
return y1;
|
||||
}
|
||||
|
||||
public void setY1(float y1) {
|
||||
this.y1 = y1;
|
||||
}
|
||||
|
||||
public float getX2() {
|
||||
return x2;
|
||||
}
|
||||
|
||||
public void setX2(float x2) {
|
||||
this.x2 = x2;
|
||||
}
|
||||
|
||||
public float getY2() {
|
||||
return y2;
|
||||
}
|
||||
|
||||
public void setY2(float y2) {
|
||||
this.y2 = y2;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public float getConfidence() {
|
||||
return confidence;
|
||||
}
|
||||
|
||||
public void setConfidence(float confidence) {
|
||||
this.confidence = confidence;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Plate{" +
|
||||
"x1=" + x1 +
|
||||
", y1=" + y1 +
|
||||
", x2=" + x2 +
|
||||
", y2=" + y2 +
|
||||
", type=" + type +
|
||||
", confidence=" + confidence +
|
||||
", code='" + code + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package com.hyperai.hyperlpr3.core;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.hyperai.hyperlpr3.bean.HyperLPRParameter;
|
||||
import com.hyperai.hyperlpr3.bean.Plate;
|
||||
|
||||
public class HyperLPRCore {
|
||||
|
||||
final String TAG = "HyperLPRCore";
|
||||
|
||||
static {
|
||||
System.loadLibrary("hyperlpr3");
|
||||
}
|
||||
|
||||
private long ctxHandle_;
|
||||
|
||||
private boolean isRunning_;
|
||||
|
||||
public void createRecognizerContext(HyperLPRParameter parameter) {
|
||||
ctxHandle_ = CreateRecognizerContext(parameter);
|
||||
Log.i(TAG, "HANDLE: " + ctxHandle_);
|
||||
isRunning_ = true;
|
||||
}
|
||||
|
||||
public Plate[] plateRecognitionFromBuffer(byte[] buf, int height, int width, int rotation, int format) {
|
||||
return PlateRecognitionFromBuffer(ctxHandle_, buf, height, width, rotation, format);
|
||||
}
|
||||
|
||||
public Plate[] plateRecognitionFromImage(int[] buf, int height, int width, int rotation, int format) {
|
||||
return PlateRecognitionFromImage(ctxHandle_, buf, height, width, rotation, format);
|
||||
}
|
||||
|
||||
public int release() {
|
||||
int ret = -1;
|
||||
if (isRunning_) {
|
||||
ret = ReleaseRecognizerContext(ctxHandle_);
|
||||
isRunning_ = false;
|
||||
ctxHandle_ = 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ===================Native==================
|
||||
|
||||
// native void TestBuffer(String savePath, byte[] buf, int height, int width, int rotation);
|
||||
|
||||
native long CreateRecognizerContext(HyperLPRParameter parameterObj);
|
||||
|
||||
native int ReleaseRecognizerContext(long handle);
|
||||
|
||||
native Plate[] PlateRecognitionFromBuffer(long handle, byte[] buf, int height, int width, int rotation, int format);
|
||||
|
||||
native Plate[] PlateRecognitionFromImage(long handle, int[] buf, int height, int width, int rotation, int format);
|
||||
|
||||
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package com.hyperai.hyperlpr3.settings;
|
||||
|
||||
public class SDKConfig {
|
||||
|
||||
public static final String packDirName = "r2_mobile";
|
||||
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package com.hyperai.hyperlpr3.settings;
|
||||
|
||||
public class TypeDefine {
|
||||
|
||||
/** 四种情况的转角 */
|
||||
public static final int CAMERA_ROTATION_0 = 0;
|
||||
public static final int CAMERA_ROTATION_90 = 1;
|
||||
public static final int CAMERA_ROTATION_180 = 2;
|
||||
public static final int CAMERA_ROTATION_270 = 3;
|
||||
|
||||
/** 低开销检测模式 */
|
||||
public static final int DETECT_LEVEL_LOW = 0;
|
||||
/** 高开销检测模式 */
|
||||
public static final int DETECT_LEVEL_HIGH = 1;
|
||||
|
||||
/** Image in RGB format - RGB排列格式的图像 */
|
||||
public static final int STREAM_RGB = 0;
|
||||
/** Image in BGR format (Opencv Mat default) - BGR排列格式的图像(OpenCV的Mat默认) */
|
||||
public static final int STREAM_BGR = 1;
|
||||
/** Image in RGB with alpha channel format -带alpha通道的RGB排列格式的图像 */
|
||||
public static final int STREAM_RGBA = 2;
|
||||
/** Image in BGR with alpha channel format -带alpha通道的BGR排列格式的图像 */
|
||||
public static final int STREAM_BGRA = 3;
|
||||
/** Image in YUV NV12 format - YUV NV12排列的图像格式 */
|
||||
public static final int STREAM_YUV_NV12 = 4;
|
||||
/** Image in YUV NV21 format - YUV NV21排列的图像格式 */
|
||||
public static final int STREAM_YUV_NV21 = 5;
|
||||
|
||||
|
||||
/** 未知车牌 */
|
||||
public static final int PLATE_TYPE_UNKNOWN = -1;
|
||||
/** 蓝牌 */
|
||||
public static final int PLATE_TYPE_BLUE = 0;
|
||||
/** 黄牌单层 */
|
||||
public static final int PLATE_TYPE_YELLOW_SINGLE = 1;
|
||||
/** 白牌单层 */
|
||||
public static final int PLATE_TYPE_WHILE_SINGLE = 2;
|
||||
/** 绿牌新能源 */
|
||||
public static final int PLATE_TYPE_GREEN = 3;
|
||||
/** 黑牌港澳 */
|
||||
public static final int PLATE_TYPE_BLACK_HK_MACAO = 4;
|
||||
/** 香港单层 */
|
||||
public static final int PLATE_TYPE_HK_SINGLE = 5;
|
||||
/** 香港双层 */
|
||||
public static final int PLATE_TYPE_HK_DOUBLE = 6;
|
||||
/** 澳门单层 */
|
||||
public static final int PLATE_TYPE_MACAO_SINGLE = 7;
|
||||
/** 澳门双层 */
|
||||
public static final int PLATE_TYPE_MACAO_DOUBLE = 8;
|
||||
/** 黄牌双层 */
|
||||
public static final int PLATE_TYPE_YELLOW_DOUBLE = 9;
|
||||
|
||||
public static final String[] PLATE_TYPE_MAPS = {"蓝牌", "黄牌单层", "白牌单层", "绿牌新能源", "黑牌港澳", "香港单层", "香港双层", "澳门单层", "澳门双层", "黄牌双层"};
|
||||
}
|
@ -1,129 +0,0 @@
|
||||
package com.hyperai.hyperlpr3.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.AssetManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.DashPathEffect;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class SDKUtils {
|
||||
static public void copyFilesFromAssets(Context context, String oldPath, String newPath) {
|
||||
try {
|
||||
String[] fileNames = context.getAssets().list(oldPath);
|
||||
if (fileNames.length > 0) {
|
||||
// directory
|
||||
File file = new File(newPath);
|
||||
if (!file.mkdir()) {
|
||||
Log.d("mkdir", "can't make folder");
|
||||
}
|
||||
// return false; // copy recursively
|
||||
for (String fileName : fileNames) {
|
||||
copyFilesFromAssets(context, oldPath + "/" + fileName,
|
||||
newPath + "/" + fileName);
|
||||
}
|
||||
} else {
|
||||
// file
|
||||
InputStream is = context.getAssets().open(oldPath);
|
||||
FileOutputStream fos = new FileOutputStream(new File(newPath));
|
||||
byte[] buffer = new byte[1024];
|
||||
int byteCount;
|
||||
while ((byteCount = is.read(buffer)) != -1) {
|
||||
fos.write(buffer, 0, byteCount);
|
||||
}
|
||||
fos.flush();
|
||||
is.close();
|
||||
fos.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static public void mkdirsFeaturesAssets(Context context, String path, String images, String features) {
|
||||
try {
|
||||
File file = new File(path);
|
||||
File imagePath = new File(path + images);
|
||||
File featurePath = new File(path + features);
|
||||
if (!file.mkdir()) {
|
||||
Log.d("mkdir", "can't make folder: " + file);
|
||||
}
|
||||
if (!imagePath.mkdir()) {
|
||||
Log.d("mkdir", "can't make folder: " + imagePath);
|
||||
}
|
||||
if (!featurePath.mkdir()) {
|
||||
Log.d("mkdir", "can't make folder: " + featurePath);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static public String saveBitmap(String savePath, String name, Bitmap bitmap) throws IOException {
|
||||
File f = new File(savePath, name + ".png");
|
||||
if (f.exists()) {
|
||||
f.delete();
|
||||
}
|
||||
FileOutputStream out = new FileOutputStream(f);
|
||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
|
||||
out.flush();
|
||||
out.close();
|
||||
return f.getAbsolutePath();
|
||||
}
|
||||
|
||||
|
||||
static public boolean cropperBitmap(Bitmap bitmap, int[] rePoints, String sdcardPath, String name) {
|
||||
int newWidth = 160;
|
||||
int newHeight = 192;
|
||||
float scaleWidth = ((float) newWidth) / bitmap.getWidth();
|
||||
float scaleHeight = ((float) newHeight) / bitmap.getHeight();
|
||||
Matrix matrix = new Matrix();
|
||||
// matrix.postTranslate()
|
||||
matrix.postScale(scaleWidth, scaleHeight);
|
||||
matrix.setScale(-1, 1);
|
||||
int px = Math.max(0, rePoints[0]);
|
||||
int py = Math.max(0, rePoints[1]);
|
||||
int w = rePoints[2] - px;
|
||||
int h = rePoints[3] - py;
|
||||
int pw = (bitmap.getWidth() - w > 0) ? w - 1 : bitmap.getWidth() - 1;
|
||||
int ph = (bitmap.getHeight() - h > 0) ? h - 1 : bitmap.getHeight() - 1;
|
||||
try {
|
||||
Bitmap crop = Bitmap.createBitmap(bitmap, px, py, pw, ph, matrix, true);
|
||||
// String sdcardPath = Environment.getExternalStorageDirectory() + File.separator + Const.root + Const.save + Const.images;
|
||||
saveBitmap(sdcardPath, name, crop);
|
||||
} catch (Exception err) {
|
||||
Log.d("crop", "ext");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static Bitmap getImageFromAssetsFile(Context context, String fileName) {
|
||||
Bitmap image = null;
|
||||
AssetManager am = context.getResources().getAssets();
|
||||
try {
|
||||
InputStream is = am.open(fileName);
|
||||
image = BitmapFactory.decodeStream(is);
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue