sandromachado / openalpr-android Goto Github PK
View Code? Open in Web Editor NEWAndroid Automatic License Plate Recognition library (http://www.openalpr.com) ported for android.
License: Apache License 2.0
Android Automatic License Plate Recognition library (http://www.openalpr.com) ported for android.
License: Apache License 2.0
Right now the settings are us and eu, and while I live in the eu and eu settings works ok for me, I wonder if I could specifiy a new country in openalpr.config with more detailed settings?
Additionally I wonder if I can specify the format of the license plate, because our format is ABC-123 and at the moment we see that the component sometimes detects O as 0.
HI,
I need to change the package name, i have successfully compiled it and added in my project.
But when i am changing package name it gives me error in initializing OPEN ALPR. Now i am trying to create the .so file, but i am not able to find .cpp and Android.mk files in this project to generate .so files .
Please share link for files, it will be helpful for me.
TIA.
Hey,
I tried to implement this into a project and i have had in issue with actually getting it to give me a value of what the license plates characters are. I get this when i debug for the value of result. result={"error":true,"msg":"Error initializing Open Alpr"}. I am not sure of what the issue is. I tried using your sample project and it reached the same issue. Attached is a screenshot of the code where this issue occurs. I know that i am not missing a file where I have already tried your version and received the same problem.
The code in the photo for this method is as follows:
@OverRide
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE && resultCode == Activity.RESULT_OK) {
final ProgressDialog progress = ProgressDialog.show(this, "Loading", "Parsing result...", true);
final String openAlprConfFile = ANDROID_DATA_DIR + File.separatorChar + "runtime_data" + File.separatorChar + "openalpr.conf";
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 10;
// Picasso requires permission.WRITE_EXTERNAL_STORAGE
Picasso.with(MainActivity.this).load(destination).fit().centerCrop().into(imageView);
resultTextView.setText("Processing");
AsyncTask.execute(new Runnable() {
@Override
public void run() {
String result = OpenALPR.Factory.create(MainActivity.this, ANDROID_DATA_DIR).recognizeWithCountryRegionNConfig("eu", "", destination.getAbsolutePath(), openAlprConfFile, 10);
Log.d("OPEN ALPR", result);
try {
final Results results = new Gson().fromJson(result, Results.class);
runOnUiThread(new Runnable() {
@Override
public void run() {
if (results == null || results.getResults() == null || results.getResults().size() == 0) {
Toast.makeText(MainActivity.this, "It was not possible to detect the licence plate.", Toast.LENGTH_LONG).show();
resultTextView.setText("It was not possible to detect the licence plate.");
} else {
resultTextView.setText("Plate: " + results.getResults().get(0).getPlate()
// Trim confidence to two decimal places
+ " Confidence: " + String.format("%.2f", results.getResults().get(0).getConfidence()) + "%"
// Convert processing time to seconds and trim to two decimal places
+ " Processing time: " + String.format("%.2f", ((results.getProcessingTimeMs() / 1000.0) % 60)) + " seconds");
}
}
});
} catch (JsonSyntaxException exception) {
final ResultsError resultsError = new Gson().fromJson(result, ResultsError.class);
runOnUiThread(new Runnable() {
@Override
public void run() {
resultTextView.setText(resultsError.getMsg());
}
});
}
progress.dismiss();
}
});
}
}
Hi there!
Great project but I can't seem to get it to work...I always get a result of {"error":true,"msg":"Error initializing Open Alpr"}.
In details,
My build.gradle (Project) contains the allprojects { repositories { maven { url "https://jitpack.io" } } }
I have compile 'com.github.SandroMachado:openalpr-android:1.1.1'
in my dependencies in the build.gradle (module:app).
I also have the openalpr.conf, which I copied into the assets/runtime_data/
directory of the app. I even used a copied version of your activity, but still the same error. Any ideas?
I'm trying to build https://github.com/SandroMachado/openalpr-android for Android. It builds and launches, but after calling native method for recognizing it makes an exception. Thanks for your time and help!
The error
Caused by: java.lang.UnsatisfiedLinkError: No implementation found for java.lang.String be.mike.licenseplate.AlprJNIWrapper.recognizeWithCountryRegionNConfig(java.lang.String, java.lang.String, java.lang.String, java.lang.String, int) (tried Java_be_mike_licenseplate_AlprJNIWrapper_recognizeWithCountryRegionNConfig and Java_be_mike_licenseplate_AlprJNIWrapper_recognizeWithCountryRegionNConfig__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2I)
Also the function recognize,etc are red " Cannot resolve corresponding JNI function "
When the user takes a bad picture, no results are returned, resulting in a NullPointerException crash.
Process: com.sandro.openalprsample, PID: 4146
java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.ArrayList org.openalpr.model.Results.getResults()' on a null object reference
at com.sandro.openalprsample.MainActivity$2$1.run(MainActivity.java:104)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
The openalpr
binary is compile with a version of libpng
that contains security vulnerabilities for users or allows the collection of user data without proper disclosure.
Every app submitted for the Play Store
using the library will be rejected, due to the new validation process that checks if the application contains code that has vulnerabilities.
I'm trying to use this in my Android App, everything compiles correctly and the files DOES exists in the APK. I confirmed this by doing a InputStream to the Config file and then read it. I could do that no problem.
These are my paths to my files, and then at the bottom it says the error.
This is my Config file.
This is my MainActivity
What could go wrong?
Does anyone have settings for an Israeli license plate?
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.xross.aicar-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.xross.aicar-2/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find "libopenalpr-native.so"
I found this error when the app run on Android version 5.0.But it certainly work in Android Version 4.4. How should i solve.
Hi there, im running the sample and I changed the:
String result = OpenALPR.Factory.create(MainActivity.this, ANDROID_DATA_DIR).recognizeWithCountryRegionNConfig("us", "", destination.getAbsolutePath(), openAlprConfFile, 10);
to
String result = OpenALPR.Factory.create(MainActivity.this, ANDROID_DATA_DIR).recognizeWithCountryRegionNConfig("eu", "", destination.getAbsolutePath(), openAlprConfFile, 10);
But it can't detect any plates. What am I missing?
Hi, can you make a detailed tutorial about this openalpr library? I've been trying to import this lib to my project, but there's errors everywhere. Please help.
Hi @SandroMachado
I am stuck on indian number plates.
Can you please help me to solve this problem.
Hai there, this library not applicable for my country malaysia. When I change recognizeWithCountryRegionNConfig("ms", "", destination.getAbsolutePath(), openAlprConfFile, 30) the output textview not come out. Please consider to put my country. Thank you.
Hi,
I have a problem with adding library in gradle. I get error:
Failed to resolve: com.github.SandroMachado:openalpr-android:1.1.0
My project build.gradle:
... allprojects { repositories { jcenter() maven { url "https://jitpack.io" } } }...
and module build.gradle:
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' ... compile 'com.github.SandroMachado:openalpr-android:1.1.0' ... }
Can anyone help me?
Hi
What version are those lib?
The return of openALPR.version() is "1.1.0". Does this mean the version of openALPR is 1.1.0?
Thanks.
I imported openalpr-android into android studio but i don't find any module to run! How to configure it and run the sample in android studio!! I'm using android studio 2.1 preview 4!! If its silly I apologies but help me Please!!
Hi, the application is crashing everytime after I take picture and select it. Below is the log cat of it. It crash even with the sample apk downloaded. Any solution for it. Thanks.
01-27 13:14:11.493 18971-18971/org.openalpr.app E/dalvikvm: dlopen("/data/app-lib/org.openalpr.app-2/libopenalpr-native.so") failed: dlopen failed: "/data/app-lib/org.openalpr.app-2/libopenalpr-native.so" has unexpected e_machine: 40
01-27 13:14:11.493 18971-18971/org.openalpr.app W/dalvikvm: Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/openalpr/AlprJNIWrapper;
01-27 13:14:11.493 18971-18971/org.openalpr.app D/AndroidRuntime: Shutting down VM
01-27 13:14:11.493 18971-18971/org.openalpr.app W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x430f3140)
01-27 13:14:11.503 18971-18971/org.openalpr.app E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.openalpr.app, PID: 18971
java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app-lib/org.openalpr.app-2/libopenalpr-native.so" has unexpected e_machine: 40
at java.lang.Runtime.loadLibrary(Runtime.java:364)
at java.lang.System.loadLibrary(System.java:526)
at org.openalpr.AlprJNIWrapper.<clinit>(AlprJNIWrapper.java:13)
at org.openalpr.Alpr$Factory.create(Alpr.java:48)
at org.openalpr.app.AlprFragment$AlprTask.onPreExecute(AlprFragment.java:60)
at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:587)
at android.os.AsyncTask.execute(AsyncTask.java:535)
at org.openalpr.app.AlprFragment.onCreate(AlprFragment.java:37)
at android.app.Fragment.performCreate(Fragment.java:1678)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:859)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
at android.app.BackStackRecord.run(BackStackRecord.java:685)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1447)
at android.app.Activity.performStart(Activity.java:5420)
at android.app.Activity.performRestart(Activity.java:5477)
at android.app.Activity.performResume(Activity.java:5482)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2945)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2984)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1335)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
I had tested the openalpr project that could recognize multiple license plates. And I think the openalpr-android project which you made is also designed for that purpose. But after I tested you app, I could only get one results at most while the openalpr project get two in the same photo. Is that normal?
Hi,
As far as I get it now only armeabi-v7a is supported. Is it possible to use your library with other architecture?
Regards,
Daniel
If I want to use this library, which license affects me, only Apache 2.0 or is there actually a link to the original Openalpr that has AGPL 3.0 license?
Version 1.1.1 of openalpr-android uses old OpenCV library 2.4.9 built on 2014-04-25. There are a lot of NEON optimizations in recent OpenCV 3x which should bring better performance to openalpr-android. Please update it to the latest stable OpenCV. OpenALPR should work with OpenCV 3 without any problem.
Hi,
Great work so far :)
Just wondering if it is possible to provide templates for pattern matching, as described in the openalpr doc here:
http://doc.openalpr.com/opensource.html#pattern-matching
I've tried creating a postprocessing folder and eu.patterns, uk.patterns, gb.patterns (I'm trying to match UK number plates), but it never seems to match anything. I just get:
"matches_template":0,"region":"","region_confidence":0
for all results.
Thanks
Hi, thanks for your library
, do you know how to add support for Colombian plates
example
https://www.pruebaderuta.com/wp-content/uploads/2016/03/placa-amarilla.jpg
Hi I'm trying to add some extra trained images example parking number plate template. i trained Parking number plate image using tensorflow framework and i exported the out put trained model as .pb file format.
**My question is if i have trained .pb model file how can use or add my own trained image (template) with existing Eu?
Is this possible to do this?
Tried:
recognizeWithCountryRegionNConfig("br"...
but it did not work.
I don't know why, but the result is "" all the time. Im not getting any error on Factory.create and get GET operations takes 2 or 3 seconds to complete, so it works, but finally i
m getting just an empty string.
I'd love to test this! Cheers.
Can anyone explain why does the call to recognizeWithCountryRegionNConfig
return after 2.3 seconds even though the actual "processing time" the results return with is 0.66 seconds?
I tried with multiple images and the result always comes about 1.5 seconds or more later than the actual "processing time" that you can find in the result. Is the JNI call slow?
Here's an example of what I'm talking about:
Log.d("TEST", "starting");
String result = factory.recognizeWithCountryRegionNConfig("eu", "", file.getAbsolutePath(), openAlprConfFile, 10);
Log.d("TEST", "ended");
Log.d("TEST", "results = " + result);
prints out:
15:26:41.988 ... D/TEST: starting
15:26:44.421 ... D/TEST: ended
15:26:44.421 ... D/TEST: results = {"epoch_time":1506691604,"processing_time_ms":678.283749,"results":[{"plate": ...}]
You can see that the time between the two logs is 2.433s and the processing time is 0.678s.
How can this be avoided so real-time recognition actually becomes possible?
EDIT: I guess it might be the config initialization. But how do I use this library without supplying the config every time I want to recognize an image? Why not supply the config once when creating the AlprJNIWrapper
object? It's what all openalpr bindings do as seen here.
Hi,
Have you consider adding to your library possibility to pass image not as file path but using byte array? I am asking because I think that could speed up processing time in combination with own camera implementation.
Regards,
Daniel
Hey,
I use sample application. I changed us to eu but app was crashed during plate recognizing.
String result = OpenALPR.Factory.create(MainActivity.this, ANDROID_DATA_DIR).recognizeWithCountryRegionNConfig("eu", "", destination.getAbsolutePath(), openAlprConfFile, 10);
Log:
12-17 13:38:57.978 2318-2355/com.sandro.openalprsample D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
12-17 13:38:57.987 2318-2318/com.sandro.openalprsample D/Atlas: Validating map...
12-17 13:38:58.024 2318-2355/com.sandro.openalprsample I/Adreno-EGL: <qeglDrvAPI_eglInitialize:410>: QUALCOMM Build: 10/28/14, c33033c, Ia6306ec328
12-17 13:38:58.025 2318-2355/com.sandro.openalprsample I/OpenGLRenderer: Initialized EGL, version 1.4
12-17 13:38:58.046 2318-2355/com.sandro.openalprsample D/OpenGLRenderer: Enabling debug mode 0
12-17 13:38:58.149 2318-2318/com.sandro.openalprsample I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@300604ab time:114794351
12-17 13:39:05.914 2318-2355/com.sandro.openalprsample D/OpenGLRenderer: endAllStagingAnimators on 0xb84db010 (RippleDrawable) with handle 0xb84dadd0
12-17 13:39:35.365 2318-2318/com.sandro.openalprsample W/Settings: Setting airplane_mode_on has moved from android.provider.Settings.System to android.provider.Settings.Global, returning read-only value.
12-17 13:39:35.628 2318-2318/com.sandro.openalprsample I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@300604ab time:114831830
12-17 13:39:41.153 2318-3779/com.sandro.openalprsample A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x4 in tid 3779 (AsyncTask #1)
12-17 13:39:42.180 2318-2318/com.sandro.openalprsample I/Choreographer: Skipped 55 frames! The application may be doing too much work on its main thread.
Hello, what are the dependencies? How can I use your library in my Android Studio on Ubuntu / Linux? I've been researching a lot and it's very difficult to get something. If you can give me detailed instructions I will be very grateful.
Hi ,
Thanks a lot for the source code provided. I have been trying it on the Indian Number plates but couldn't recognise the entire number plate number totally ,it is partially working on Indian number plates ,can you help me on this.
Here are some indian number plates examples :
https://www.google.co.in/search?q=number+plate&espv=2&biw=1920&bih=963&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjrkZCxpMHSAhXFHJQKHR6nDQoQ_AUIBigB#tbm=isch&=number+plate+kerala&*&imgrc=kkVnXBef1e42aM:
Dear Sandro,
thank you for putting this together. Unfortunately the build process fails for me for both release v1.1.1 and v1.1.0. I'm building with Studio 2.2.3 and JRE 1.8.0_76-release-b03-amd64 and try to run on
If I clean and rebuild the app, the building works, but when I try to run the app I get:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/local/android-studio/jre/bin/java'' finished with non-zero exit value 2
If I use the option:
multiDexEnabled true
I get:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/sandro/openalpr/BuildConfig.class
Thank you for any help on this,
k3t0
If the user rotates the screen, the image & result will be lost. I suggest retaining the state of at least the TextView result.
If the user rotates the screen while the request is being processed, it will result in a NullPointerException crash. This is similar to #5 except this may actually still have valid data as it is delayed until the processing finishes.
Process: com.sandro.openalprsample, PID: 4146
java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.ArrayList org.openalpr.model.Results.getResults()' on a null object reference
at com.sandro.openalprsample.MainActivity$2$1.run(MainActivity.java:104)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Hi, I can speak a little English. I want to read the plate from Android application.
I'm getting an error. Test phone: LG-L90 Android: 5.0
Error:
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: fortibasedanismanlik.plate, PID: 6705
java.lang.UnsatisfiedLinkError: com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader[DexPathList[[dex file "/data/data/fortibasedanismanlik.plate/files/instant-run/dex/slice-support-annotations-23.0.1_1ac4e020d4c8fe58e32dc7d55b3c675a547a2efe-classes.dex", dex file "/data/data/fortibasedanismanlik.plate/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/fortibasedanismanlik.plate/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/fortibasedanismanlik.plate/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/fortibasedanismanlik.plate/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/fortibasedanismanlik.plate/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/fortibasedanismanlik.plate/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/fortibasedanismanlik.plate/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/fortibasedanismanlik.plate/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/fortibasedanismanlik.plate/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/fortibasedanismanlik.plate/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/fortibasedanismanlik.plate/files/instant-run/dex/slice-picasso-2.5.2_27cfa72c06fe581632ec0927aac379dc32fb8992-classes.dex", dex file "/data/data/fortibasedanismanlik.plate/files/instant-run/dex/slice-internal_impl-23.0.1_5ee279ce67983e03ad7ba03383b9ae3f02a1c09c-classes.dex", dex file "/data/data/fortibasedanismanlik.plate/files/instant-run/dex/slice-gson-2.5_de0e2f4ced45b506f8481ad283630c47e362a524-classes.dex", dex file "/data/data/fortibasedanismanlik.plate/files/instant-run/dex/slice-com.github.SandroMachado-openalpr-android-1.0.0_4bad39b75169c2cbf5aa079edeb5edbc34a5776a-classes.dex", dex file "/data/data/fortibasedanismanlik.plate/files/instant-run/dex/slice-com.android.support-support-v4-23.0.1_045c15e5c19e08c7f1f4e27118dd515c017cd47c-classes.dex", dex file "/data/data/fortibasedanismanlik.plate/files/instant-run/dex/slice-com.android.support-appcompat-v7-23.0.1_d198809873213e007bd5d1c1ef7f8f137ed0f35f-classes.dex"],nativeLibraryDirectories=[/vendor/lib, /system/lib, /vendor/lib, /system/lib]]] couldn't find "libopenalpr-native.so"
at java.lang.Runtime.loadLibrary(Runtime.java:366)
at java.lang.System.loadLibrary(System.java:989)
at org.openalpr.AlprJNIWrapper.<clinit>(AlprJNIWrapper.java:9)
at org.openalpr.OpenALPR$Factory.create(OpenALPR.java:78)
at fortibasedanismanlik.plate.MainActivity$2.run(MainActivity.java:86)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
I/art: Background sticky concurrent mark sweep GC freed 2161(536KB) AllocSpace objects, 4(64KB) LOS objects, 2% free, 7MB/7MB, paused 13.642ms total 36.305ms
I/art: CheckpointMarkThreadRoots callback created = 0xab7ffe00
I/art: CheckpointMarkThreadRoots callback created = 0xab7ffdf0
E/WindowManager: android.view.WindowLeaked: Activity fortibasedanismanlik.plate.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{91705a5 V.E..... R......D 0,0-513,242} that was originally added here
at android.view.ViewRootImpl.<init>(ViewRootImpl.java:376)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:261)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
at android.app.Dialog.show(Dialog.java:306)
at android.app.ProgressDialog.show(ProgressDialog.java:117)
at android.app.ProgressDialog.show(ProgressDialog.java:100)
at fortibasedanismanlik.plate.MainActivity.onActivityResult(MainActivity.java:72)
at android.app.Activity.dispatchActivityResult(Activity.java:6222)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3627)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3674)
at android.app.ActivityThread.access$1300(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1358)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5349)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
Codes:
Gradle:project
allprojects {
repositories {
maven { url "https://jitpack.io" }
jcenter()
}
}
Gradle:Module
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "fortibasedanismanlik.plate"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:23.0.1'
testCompile 'junit:junit:4.12'
compile('com.github.SandroMachado:openalpr-android:1.0.0@aar') {
transitive = true
}
compile 'com.google.code.gson:gson:2.5'
compile 'com.squareup.picasso:picasso:2.5.2'
}
MainActivity:
`public class MainActivity extends AppCompatActivity {
private static final int REQUEST_IMAGE = 100;
private static final int STORAGE=1;
private String ANDROID_DATA_DIR;
private static File destination;
private TextView resultTextView;
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ANDROID_DATA_DIR = this.getApplicationInfo().dataDir;
findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
checkPermission();
}
});
resultTextView = (TextView) findViewById(R.id.textView);
imageView = (ImageView) findViewById(R.id.imageView);
resultTextView.setText("Press the button below to start a request.");
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE && resultCode == Activity.RESULT_OK) {
final ProgressDialog progress = ProgressDialog.show(this, "Loading", "Parsing result...", true);
final String openAlprConfFile = ANDROID_DATA_DIR + File.separatorChar + "runtime_data" + File.separatorChar + "openalpr.conf";
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 10;
Picasso.with(MainActivity.this).load(destination).fit().centerCrop().into(imageView);
resultTextView.setText("Processing");
AsyncTask.execute(new Runnable() {
@Override
public void run() {
String result = OpenALPR.Factory.create(MainActivity.this,
ANDROID_DATA_DIR).recognizeWithCountryRegionNConfig("us"
,"",
destination.getAbsolutePath(),
openAlprConfFile, 10);
Log.d("OPEN ALPR", result);
try {
final Results results = new Gson().fromJson(result, Results.class);
runOnUiThread(new Runnable() {
@Override
public void run() {
if (results == null || results.getResults() == null || results.getResults().size() == 0) {
Toast.makeText(MainActivity.this, "It was not possible to detect the licence plate.", Toast.LENGTH_LONG).show();
resultTextView.setText("It was not possible to detect the licence plate.");
} else {
resultTextView.setText("Plate: " + results.getResults().get(0).getPlate()
// Trim confidence to two decimal places
+ " Confidence: " + String.format("%.2f", results.getResults().get(0).getConfidence()) );
}
}
});
} catch (JsonSyntaxException exception) {
final ResultsError resultsError = new Gson().fromJson(result, ResultsError.class);
runOnUiThread(new Runnable() {
@Override
public void run() {
resultTextView.setText(resultsError.getMsg());
}
});
}
progress.dismiss();
}
});
}
}
private void checkPermission() {
List<String> permissions = new ArrayList<>();
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
if (!permissions.isEmpty()) {
Toast.makeText(this, "Storage access needed to manage the picture.", Toast.LENGTH_LONG).show();
String[] params = permissions.toArray(new String[permissions.size()]);
ActivityCompat.requestPermissions(this, params, STORAGE);
} else { // We already have permissions, so handle as normal
takePicture();
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
switch (requestCode) {
case STORAGE:{
Map<String, Integer> perms = new HashMap<>();
// Initial
perms.put(Manifest.permission.WRITE_EXTERNAL_STORAGE, PackageManager.PERMISSION_GRANTED);
// Fill with results
for (int i = 0; i < permissions.length; i++)
perms.put(permissions[i], grantResults[i]);
// Check for WRITE_EXTERNAL_STORAGE
Boolean storage = perms.get(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
if (storage) {
// permission was granted, yay!
takePicture();
} else {
// Permission Denied
Toast.makeText(this, "Storage permission is needed to analyse the picture.", Toast.LENGTH_LONG).show();
}
}
default:
break;
}
}
public String dateToString(Date date, String format) {
SimpleDateFormat df = new SimpleDateFormat(format, Locale.getDefault());
return df.format(date);
}
public void takePicture() {
// Use a folder to store all results
File folder = new File(Environment.getExternalStorageDirectory() + "/OpenALPR/");
if (!folder.exists()) {
folder.mkdir();
}
// Generate the path for the next photo
String name = dateToString(new Date(), "yyyy-MM-dd-hh-mm-ss");
destination = new File(folder, name + ".jpg");
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(destination));
startActivityForResult(intent, REQUEST_IMAGE);
}
@Override
protected void onResume() {
super.onResume();
if (destination != null) {// Picasso does not seem to have an issue with a null value, but to be safe
Picasso.with(MainActivity.this).load(destination).fit().centerCrop().into(imageView);
}
}
}`
What could be the problem? Thanks.
I'm from Mongolia and i'm planning on using this. And i have to clarify something like does it work with cyrillic fonts, is it able to modify ocr with my own trained fonts etc..
Testing your application and I am receiving a crash when submitting the image. This was tested using the Sample app source code from this repository on a Nexus 6 running Android 6.0.1.
FATAL EXCEPTION: AsyncTask #1
Process: com.sandro.openalprsample, PID: 12850
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.sandro.openalprsample-1/base.apk"],nativeLibraryDirectories=[/data/app/com.sandro.openalprsample-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libopenalpr-native.so"
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:1076)
at org.openalpr.AlprJNIWrapper.<clinit>(AlprJNIWrapper.java:9)
at org.openalpr.OpenALPR$Factory.create(OpenALPR.java:78)
at com.sandro.openalprsample.MainActivity$2.run(MainActivity.java:87)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Force finishing activity com.sandro.openalprsample/.MainActivity
Screenshot max retries 4 of Token{5009e4b ActivityRecord{537f31a u0 com.sandro.openalprsample/.MainActivity t5613 f}} appWin=Window{73392ed u0 com.sandro.openalprsample/com.sandro.openalprsample.MainActivity} drawState=3
Process com.sandro.openalprsample (pid 12850) has died
Is there a way to check for seperators like in german plates? Here's an example, the license plate detected is DNP666.
In Germany, the left part of the plate is the region, in the example it's "DN". The right part can be one or two letters followed by 1 to 4 numbers. So, DN-P666 like in the example could also be D-NP666 - depending on where the free space is.
Is there a way to distinguish D-NP666 and DN-P666 ?
hi,
i have thisissue , please help me
02-01 21:34:54.761 7599-7599/com.neo.testopencv E/linker: soinfo_link_image(linker.cpp:1652): could not load library "libopencv_java.so" needed by "libopenalpr-native.so"; caused by load_library(linker.cpp:759): library "libopencv_java.so" not found 02-01 21:34:54.761 7599-7599/com.neo.testopencv E/dalvikvm: dlopen("/data/app-lib/com.neo.testopencv-2/libopenalpr-native.so") failed: Cannot load library: soinfo_link_image(linker.cpp:1652): could not load library "libopencv_java.so" needed by "libopenalpr-native.so"; caused by load_library(linker.cpp:759): library "libopencv_java.so" not found 02-01 21:34:54.766 7599-7599/com.neo.testopencv E/AndroidRuntime: FATAL EXCEPTION: main java.lang.UnsatisfiedLinkError: Cannot load library: soinfo_link_image(linker.cpp:1652): could not load library "libopencv_java.so" needed by "libopenalpr-native.so"; caused by load_library(linker.cpp:759): library "libopencv_java.so" not found at java.lang.Runtime.loadLibrary(Runtime.java:372) at java.lang.System.loadLibrary(System.java:514) at org.openalpr.AlprJNIWrapper.<clinit>(AlprJNIWrapper.java:9) at org.openalpr.OpenALPR$Factory.create(OpenALPR.java:78) at com.neo.testopencv.MainActivity.onActivityResult(MainActivity.java:61) at android.app.Activity.dispatchActivityResult(Activity.java:5383) at android.app.ActivityThread.deliverResults(ActivityThread.java:3575) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3622) at android.app.ActivityThread.access$1100(ActivityThread.java:169) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1436) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5433) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:924) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:691) at dalvik.system.NativeStart.main(Native Method)
Hi,
I would like to know how to use this library to recognize plates with live video capture. Can you provide some path or example on how to integrate that?
Hi,
I get an error when I include the project.
Log output: D/OPEN ALPR: {"error":true,"msg":"Error initializing Open Alpr"}
gradle :
MainActivity:
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.Toast;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import org.openalpr.OpenALPR;
import org.openalpr.model.Results;
import org.openalpr.model.ResultsError;
import java.io.File;
public class MainActivity extends AppCompatActivity {
private String ANDROID_DATA_DIR;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Uri path = Uri.parse("android.resource://com.nikhil.material/" + R.drawable.car);
ANDROID_DATA_DIR = this.getApplicationInfo().dataDir;
final String openAlprConfFile = ANDROID_DATA_DIR + File.separatorChar + "runtime_data" + File.separatorChar + "openalpr.conf";
AsyncTask.execute(new Runnable() {
@Override
public void run() {
String result = OpenALPR.Factory.create(MainActivity.this, ANDROID_DATA_DIR).recognizeWithCountryRegionNConfig("eu", "", path.toString(), openAlprConfFile, 10);
Log.d("OPEN ALPR", result);
try {
final Results results = new Gson().fromJson(result, Results.class);
runOnUiThread(new Runnable() {
@Override
public void run() {
if (results == null || results.getResults() == null || results.getResults().size() == 0) {
Toast.makeText(MainActivity.this, "It was not possible to detect the licence plate.", Toast.LENGTH_LONG).show();
Log.d("Error", "It was not possible to detect the licence plate.");
} else {
Log.d("Plate: ", results.getResults().get(0).getPlate());
}
}
});
} catch (JsonSyntaxException exception) {
final ResultsError resultsError = new Gson().fromJson(result, ResultsError.class);
runOnUiThread(new Runnable() {
@Override
public void run() {
Log.d("Error :", resultsError.getMsg());
}
});
}
}
});
}
}
Error :
Where is the problem? Thanks.
may i know this lib only recognize License? could recognize other words? and when i take picture with this "3SAM123", it prompts "it was unpossible to detect the lincence plate".
The application can't recognize the belgium plate ex. formta : 1-ABC-235.
Is there an issue for that ?
Someone can help me ?
Thanks
hi, i have this issue,
anyone can help me???
opencv E/linker: load_library(linker.cpp:759): library "libopencv_java.so" not found 02-01 22:00:18.204 11789-11789/com.neo.testopencv E/linker: soinfo_link_image(linker.cpp:1652): could not load library "libopencv_java.so" needed by "libopenalpr-native.so"; caused by load_library(linker.cpp:759): library "libopencv_java.so" not found 02-01 22:00:18.204 11789-11789/com.neo.testopencv E/dalvikvm: dlopen("/data/app-lib/com.neo.testopencv-1/libopenalpr-native.so") failed: Cannot load library: soinfo_link_image(linker.cpp:1652): could not load library "libopencv_java.so" needed by "libopenalpr-native.so"; caused by load_library(linker.cpp:759): library "libopencv_java.so" not found 02-01 22:00:18.209 11789-11789/com.neo.testopencv E/AndroidRuntime: FATAL EXCEPTION: main java.lang.UnsatisfiedLinkError: Cannot load library: soinfo_link_image(linker.cpp:1652): could not load library "libopencv_java.so" needed by "libopenalpr-native.so"; caused by load_library(linker.cpp:759): library "libopencv_java.so" not found at java.lang.Runtime.loadLibrary(Runtime.java:372) at java.lang.System.loadLibrary(System.java:514) at org.openalpr.AlprJNIWrapper.<clinit>(AlprJNIWrapper.java:9) at org.openalpr.OpenALPR$Factory.create(OpenALPR.java:78) at com.neo.testopencv.MainActivity.onActivityResult(MainActivity.java:61) at android.app.Activity.dispatchActivityResult(Activity.java:5383) at android.app.ActivityThread.deliverResults(ActivityThread.java:3575) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3622) at android.app.ActivityThread.access$1100(ActivityThread.java:169) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1436) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5433) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:924) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:691) at dalvik.system.NativeStart.main(Native Method)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.