SandroMachado / openalpr-android

Android Automatic License Plate Recognition library (http://www.openalpr.com) ported for android.
Apache License 2.0
770 stars 272 forks source link

Recognition performance longer than "processing time" #57

Open mj3c opened 6 years ago

mj3c commented 6 years ago

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.