Click here to Skip to main content
15,936,122 members
Articles / Artificial Intelligence / Deep Learning

Live Lightning Detection with Deep Learning and Tensorflow on Android: Real-time Testing

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
17 Nov 2020CPOL2 min read 4.6K   37  
In this article we’ll carry out real-time testing of our app.
Here we discuss the real-time testing of our app on two Android devices.


In the previous article, we went over the TFLite model setup in the Android environment, up to a working demo application.

In this one, we’ll do some real-time testing on Android devices.


I have tested the app with two different devices – Samsung SM-A710FD and Huawei MediaPad T3 10 – both with the Android version 7.0.

A piece of advice: don’t test the app in your room because anything and everything that emits or reflects light will be detected as a lightning. This is what we’ve trained our model to do, right? The almost 300 images in our dataset all show the lightning striking at night. This means black background and a light object - which is detected as lightning. The same thing happens when you point your phone or tablet camera to a computer screen or the light source on the ceiling. I suggest you test the app outside, at night, targeting something like street lights as a lightning substitute. I did a test with an iPhone – opened up a lightning image on it and targeted the screen with the Android device running the app. And yes: the app detected lightning!

Note that the targeting (camera pointing) should be abrupt so as to mimic the abrupt appearance of the real lightning.

Manual Testing

For manual testing, I took my Android phone, Huawei tablet, and iPhone (loaded with the lightning images) to my balcony. It was a beautiful, clear night. Then I ran the app on my Android device. Have a look at the resulting video and screenshots.

Image 1

Image 2

Image 3

Image 4

Image 5

Image 6

Image 7

Image 8

Image 9

Image 10

Image 11

Image 12

Same for the Huawei tablet – see video and screenshots.

Image 13

Image 14

Image 15

Image 16

Image 17

Image 18

Image 19

Image 20

Magic, right? As I have mentioned earlier, any emitted or reflected light would be detected as lightning. To make the model work more accurately, you can train it more. I did the training with approximately 300 images. Give it a try with a larger dataset, say 1000 images.

Next Steps

In the next article, we’ll discuss the project outcome and "lessons learned" – how the approach we’ve followed can be utilized for similar detection tasks. Stay tuned!

This article is part of the series 'Live Lightning Detection with Deep Learning and Tensorflow on Android View All


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Technical Writer
Canada Canada | Technical Specialist & Author

Comments and Discussions

-- There are no messages in this forum --