A Open-source Xamarin integration for OpenALPR. (Only supports Android at the moment. Anyone is welcome to port it to Xamarin.iOS)
Ever wanted to use OpenALPR with Xamarin but never could? Look no further! After tons of research and testing, I've developed a solution that uses the Native JNI Libraries in combination with Android AAR libraries to create a Xamarin Library that can be used to execute OpenALPR recognition.
-
OpenALPR Xamarin.Android Binding which is used to bind the .AAR file generated from SandroMachado's Android Project. This creates a bindable DLL to use in the next bullet.
-
OpenALPR Xamarin.Android Library which is used to bind the previous Binding into a neat and easy assembly for management and execution.
-
OpenALPR Xamarin.Android Sample App which is used for testing purposes and showing a sample of how the solution works.
-
Releases which contains all the nercessary files to use OpenALPR in your project (taking into consideration that you've followed the below guide)
- Android 4.1+
- Latest version of Xamarin (Not tested on older versions)
- Newtonsoft.Json
To use OpenALPR in your Xamarin project, here's a guide on how to do it.
- First off, reference the
OpenALPR Xamarin.Android Library
file which is located in the Releases folder - Now reference these 2 files also (Both can be retrieved from
C:\Windows\Microsoft.NET\Framework\v4.0.30319
:- System.Drawing.dll
- System.Configuration.dll
- You also need to reference Newtonsoft.Json which you can get from NuGet
- Copy the folder "lib" from the Releases and Libraries folder in the Git repository, and place it (with it's libraries) in your Project Folder. Mark ALL of them as
AndroidNativeLibrary
- Go to your Project Properties -> Android Options and uncheck
Use Shared Runtime
and set the Linking property toNone
- Copy the runtime_data folder from OpenALPR into your Assets folder of your Project, together with the openalpr.conf file.
Now that the Installation part is done, let's see how it actually is used.
- Create an instance of the
OpenALPR
class and fill out the paths of where you placed your OpenALPR data.
OpenALPRInstance = new OpenALPR(this, AndroidDataDir, OpenALPRConfigFile, "eu");
- After this, you are able to execute the the Recognize function.
OpenALPR_Results results = OpenALPRInstance.Recognize(ImagePath);
if(results.DidErrorOccur == false)
{
string output = "";
foreach (var flp in results.FoundLicensePlates)
{
output += "Best: " + flp.BestLicensePlate + "(" + flp.Confidence + "%)\n";
foreach (var oc in flp.OtherCandidates)
{
output += "- " + oc.LicensePlate + "(" + oc.Confidence + "%)\n";
}
}
//Show output
} else
{
// Handle error scenario..
}
- Not supported at the moment, anyone is welcome to port it
Feel free to make a Pull Request and further develop this! An iOS version of this would be very cool to see! I will however be making updates and changes to the Android version of the library to increase recognition speed, reduce file size, etc.
If you want to reach out to me, you can do so by multiple ways:
- Twitter (@KevinJPetersen)
- Email: [email protected]
- LinkedIn (http://linkedin.com/in/publicvoid/)
- Or simply by posting an "Issue" on this Github :)
- Java code from SandroMachado (https://github.com/SandroMachado/openalpr-android) which was used to create an AAR library
- OpenALPR (for making the core functionality behind the Recognition technology) (https://github.com/openalpr/openalpr)