Add Android Demo

This commit is contained in:
tunm
2023-02-28 00:47:31 +08:00
parent 554a25edaa
commit ea70bf116a
22 changed files with 324 additions and 36 deletions
+1
View File
@@ -44,4 +44,5 @@ dependencies {
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.github.smuyyh:ImageSelector:3.0'
}
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hyperai.hyperlpr3">
</manifest>
@@ -1,6 +1,7 @@
package com.hyperai.hyperlpr3;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.Log;
import com.hyperai.hyperlpr3.api.APIDefine;
@@ -60,5 +61,22 @@ public class HyperLPR3 extends TypeDefine implements APIDefine {
return mCore.plateRecognitionFromBuffer(buf, height, width, rotation, format);
}
/**
* License plate recognition interface.
*
* @param image Bitmap image
* @param rotation Original data buffer rotation Angle
* @param format Buffer data coded format
* @return Resulting object array
*/
@Override
public Plate[] plateRecognition(Bitmap image, int rotation, int format) {
int mWidth = image.getWidth();
int mHeight = image.getHeight();
int[] data = new int[image.getWidth() * image.getHeight()];
image.getPixels(data, 0, mWidth, 0, 0, mWidth, mHeight);
return mCore.plateRecognitionFromImage(data, mHeight, mWidth, rotation, format);
}
}
@@ -1,5 +1,7 @@
package com.hyperai.hyperlpr3.api;
import android.graphics.Bitmap;
import com.hyperai.hyperlpr3.bean.Plate;
public interface APIDefine {
@@ -15,4 +17,13 @@ public interface APIDefine {
*/
Plate[] plateRecognition(byte[] buf, int height, int width, int rotation, int format);
/**
* License plate recognition interface.
* @param image Bitmap image
* @param rotation Original data buffer rotation Angle
* @param format Buffer data coded format
* @return Resulting object array
*/
Plate[] plateRecognition(Bitmap image, int rotation, int format);
}
@@ -31,6 +31,10 @@ public class HyperLPRCore {
return PlateRecognitionFromBuffer(ctxHandle_, buf, height, width, rotation, format);
}
public Plate[] plateRecognitionFromImage(int[] buf, int height, int width, int rotation, int format) {
return PlateRecognitionFromImage(ctxHandle_, buf, height, width, rotation, format);
}
public int release() {
int ret = -1;
if (isRunning_) {
@@ -50,4 +54,8 @@ public class HyperLPRCore {
native int ReleaseRecognizerContext(long handle);
native Plate[] PlateRecognitionFromBuffer(long handle, byte[] buf, int height, int width, int rotation, int format);
native Plate[] PlateRecognitionFromImage(long handle, int[] buf, int height, int width, int rotation, int format);
}