My “Quick” Journey Creating License Plate Recognition on Android With TensorFlow 2

Android TensorFlow TFLite license plate 1-liner image recognition demo based on LPRNet

Cefaci
Cefaci
Sep 29, 2020 · 7 min read
Image for post
Image for post
4LPR screenshot — Photo credit by Roman Kraft

TL;DR

Preface

OpenALPR

Results

”In our use case it was faster to type the plate directly instead (i used to work in a car reselling industry for those who care ^^)”.

Machine learning — TensorFlow

Image Recognition

Data

Learning

CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ÄÖÜ-.*_/=·: "

Export to TFLite

@tf.function
def decode(logits, top_paths=10, beam_width=100):
batch_size_current, timesteps, _ = tf.shape(input=logits)
seq_len = tf.fill([batch_size_current], timesteps)
logits = tf.transpose(a=logits, perm=(1, 0, 2))
decoded, log_probabilities =
tf.nn.ctc_beam_search_decoder(inputs=logits,
top_paths=top_paths, beam_width=beam_width,
sequence_length=seq_len)
return decoded
bazel build --cxxopt='--std=c++14' -c opt \
--fat_apk_cpu=arm64-v8a,armeabi-v7a --config=monolithic \
//tensorflow/lite/experimental/kernels:all \
//tensorflow/lite/java:tensorflow-lite \
//tensorflow/lite/java:tensorflow-lite-gpu \
//tensorflow/lite/delegates/flex:delegate \
//tensorflow/lite/java:tensorflow-lite-select-tf-ops
bazel build --cxxopt='--std=c++14' -c opt \
--fat_apk_cpu=arm64-v8a,armeabi-v7a --config=monolithic \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
//tensorflow/lite/java:tensorflow-lite \
//tensorflow/lite/java:tensorflow-lite-gpu \
//tensorflow/lite/delegates/flex:delegate \
//tensorflow/lite/experimental/kernels:ctc_beam_search_decoder_op \
//tmp:tensorflow-lite-select-tf-ops

Android

Object Detection

Data

Training

TFLite export TensorFlow 1/2

Image for post
Image for post
4LPR screenshot — Photo credit by Roman Kraft

Results and Videos

4LPR video screen recording—Testing the demo version on a night walk.
4LPR video screen recording — Pre-version daylight walk w/ buggy trackers.
4LPR video screen recording — Image on a screen tracked

The Startup

Medium's largest active publication, followed by +756K people. Follow to join our community.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store