Thursday, April 15, 2021
  • Setup menu at Appearance » Menus and assign menu to Top Bar Navigation
Advertisement
  • AI Development
    • Artificial Intelligence
    • Machine Learning
    • Neural Networks
    • Learn to Code
  • Data
    • Blockchain
    • Big Data
    • Data Science
  • IT Security
    • Internet Privacy
    • Internet Security
  • Marketing
    • Digital Marketing
    • Marketing Technology
  • Technology Companies
  • Crypto News
No Result
View All Result
NikolaNews
  • AI Development
    • Artificial Intelligence
    • Machine Learning
    • Neural Networks
    • Learn to Code
  • Data
    • Blockchain
    • Big Data
    • Data Science
  • IT Security
    • Internet Privacy
    • Internet Security
  • Marketing
    • Digital Marketing
    • Marketing Technology
  • Technology Companies
  • Crypto News
No Result
View All Result
NikolaNews
No Result
View All Result
Home Neural Networks

Image Stream Processing in Flutter application by TFLite Neural Networks | by Vadym Pinchuk | Aug, 2020

September 11, 2020
in Neural Networks
Image Stream Processing in Flutter application by TFLite Neural Networks | by Vadym Pinchuk | Aug, 2020
587
SHARES
3.3k
VIEWS
Share on FacebookShare on Twitter

Depending on a task and requirements, there is a solution which might cause some ‘freezing’ issues, but in the end its overall result generally satisfies the requirements. When resolution matters and image update frequency is not so important (for example, from three to five frames in a second are acceptable), you can pick frames from camera, process them, show results, and perform all these steps in a cycle.

ML Jobs

Some common camera configurations

You might also like

5 Ways Conversational AI is Shaping the Future of Learning | by Aurosikha Priyadarshini | Apr, 2021

Data Labeling Service — How to Get Good Training Data for ML Project? | by ByteBridge | Apr, 2021

How to Enter Your First Zindi Competition | by Davis David

To make this app work with a camera, first it needs to be configured. A camera controller is configured as shown or as you wish, according to your requirements, and followed by camera plugin samples.

Camera controller initialisation

Image capturing is also simple. Provide image url. Take a picture (frame) and save it. Here you could see some pieces of BLoC events triggering:

Very draft version of proper image capturing logic

While the main frame picking logic is here:

Quite standard picture capturing logic

I have also added some kind of cache to save 10 latest frames for processing and cleaning operation to be performed in a separate isolate. You could find that in a sample application.

1. Microsoft Azure Machine Learning x Udacity — Lesson 4 Notes

2. Fundamentals of AI, ML and Deep Learning for Product Managers

3. Roadmap to Data Science

4. Work on Artificial Intelligence Projects

Flutter widgets, building prerequisites

To work properly with a camera and a memory, some more configurations are required. I have used the permission handler plugin wrapped in Permissions BLoC to handle all this stuff, also connected to Lifecycle BLoC to stop the processes when the app is in background (collapsed) and to Cameras BLoC for requesting the available cameras list and update UI, depending on the data. So main detector component functionality is the following:

MultiBlocProvider wrapper with general configuration BLoCs

More detailed functionality could be found in BLoC files.

Detector widget in Component wrapped in MultiBlocProvider with two main BLoCs: Detector and Cropper. They are quite local and should not be used over the application only in this particular part:

MultiBlocProvider wrapper over main widget with camera view

More business logic is here

For this application I have used a BLoC architecture solution. While I am a fan of Redux pattern for approaches to split: UI, state storage, state change and business logic, BLoC is still event-driven and quite simple for understanding, based on streams. Some plugins implementing the bloc provide simpler solutions, wrapping all streams handling inside. So i stuck on flutter_bloc. Thanks to Felix Angelov, I was inspired by his talk on Flutter Europe.

The general flow of image detection is shown in this piece of Detector’s BLoC code:

Please don’t blame me for event throwing from constructors body. I will change it, I swear

Detailed method explanation will follow.

Responsible for image cropping Cropper BLoC:

Image cropping BLoC might be changed if Utils will be an Object, not a bunch static functions

For better understanding, the next section contains code examples for all internally-used methods from utils.dart class.

Object detection on ‘image stream’

I had a task to run object detection on a camera stream, draw their frames on a screen, cropp these objects (if needed), and send them to some other component for post processing.

For this task I have checked a few solutions. Firebase ML does not allow using custom-trained models locally, for now. Yes, there is a great article with Firestore, which I have not checked yet.

Models loading

For my first implementation I have used an easier solution on an existing tflite plugin. Pre-trained models for this article application have also been taken from their sample application. It allows loading custom-trained neural networks right from the device. And it worked .

Model initialisation function

Detection logic

Detection is quite straightforward. For this you need to load the image path to TFLite, and, as a result, get detected objects as a list of coordinate boxes with recognized object labels.

Object detection function in Utils class

This method is also wrapped into the Exif image rotation function from plugin to get a proper image angle; as I have found out (after some painful debugging), on most devices images are saved with a rotation of 90 degrees.

Object cropping

A simple method to copy bytes from the original image matrix to the resulting image matrix. Pixel by pixel. One by one.

Here you can find _copyCropp method which performs image data copying from original source to cropped destination.

Some pitfalls

While working on the plugin, I have found out that cropped images are always of the same size. I configured the camera controller to get the maximum image size. But it was constantly the same. After some research I found an issue in a camera plugin, which actually returns a high-quality size as upper bound. Surprise )

To get a proper image size, for future boxes displaying on the camera stream, I had to do this:

Reading image size for proper detection boxes displaying

All these pieces are used one by one, cycled and connected to the application lifecycle.

Credit: BecomingHuman By: Vadym Pinchuk

Previous Post

How to Ask Great Questions at Work

Next Post

Partnerships, Allies Critical to Defense Department Artificial Intelligence > U.S. DEPARTMENT OF DEFENSE > Defense Department News

Related Posts

5 Ways Conversational AI is Shaping the Future of Learning | by Aurosikha Priyadarshini | Apr, 2021
Neural Networks

5 Ways Conversational AI is Shaping the Future of Learning | by Aurosikha Priyadarshini | Apr, 2021

April 15, 2021
Data Labeling Service — How to Get Good Training Data for ML Project? | by ByteBridge | Apr, 2021
Neural Networks

Data Labeling Service — How to Get Good Training Data for ML Project? | by ByteBridge | Apr, 2021

April 14, 2021
How to Enter Your First Zindi Competition | by Davis David
Neural Networks

How to Enter Your First Zindi Competition | by Davis David

April 14, 2021
Why I Think That Avengers: Age of Ultron is One of the Best Sci-Fi Movies About A.I | by Brighton Nkomo | Apr, 2021
Neural Networks

Why I Think That Avengers: Age of Ultron is One of the Best Sci-Fi Movies About A.I | by Brighton Nkomo | Apr, 2021

April 14, 2021
Music and Artificial Intelligence | by Ryan M. Raiker, MBA | Apr, 2021
Neural Networks

Music and Artificial Intelligence | by Ryan M. Raiker, MBA | Apr, 2021

April 13, 2021
Next Post
Partnerships, Allies Critical to Defense Department Artificial Intelligence > U.S. DEPARTMENT OF DEFENSE > Defense Department News

Partnerships, Allies Critical to Defense Department Artificial Intelligence > U.S. DEPARTMENT OF DEFENSE > Defense Department News

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended

Plasticity in Deep Learning: Dynamic Adaptations for AI Self-Driving Cars

Plasticity in Deep Learning: Dynamic Adaptations for AI Self-Driving Cars

January 6, 2019
Microsoft, Google Use Artificial Intelligence to Fight Hackers

Microsoft, Google Use Artificial Intelligence to Fight Hackers

January 6, 2019

Categories

  • Artificial Intelligence
  • Big Data
  • Blockchain
  • Crypto News
  • Data Science
  • Digital Marketing
  • Internet Privacy
  • Internet Security
  • Learn to Code
  • Machine Learning
  • Marketing Technology
  • Neural Networks
  • Technology Companies

Don't miss it

Three Privacy Preserving Machine Learning Techniques Solving This Decade’s Most Important Issue
Machine Learning

Three Privacy Preserving Machine Learning Techniques Solving This Decade’s Most Important Issue

April 15, 2021
5 Ways Conversational AI is Shaping the Future of Learning | by Aurosikha Priyadarshini | Apr, 2021
Neural Networks

5 Ways Conversational AI is Shaping the Future of Learning | by Aurosikha Priyadarshini | Apr, 2021

April 15, 2021
Marketing Automation Technology for Revenue & Growth
Marketing Technology

Marketing Automation Technology for Revenue & Growth

April 15, 2021
Six courses to build your technology skills in 2021 – IBM Developer
Technology Companies

A brief intro to Red Hat OpenShift for Node.js developers – IBM Developer

April 15, 2021
Microsoft Defender for Endpoint now protects unmanaged BYO devices
Internet Security

Microsoft Defender for Endpoint now protects unmanaged BYO devices

April 15, 2021
New JavaScript Exploit Can Now Carry Out DDR4 Rowhammer Attacks
Internet Privacy

New JavaScript Exploit Can Now Carry Out DDR4 Rowhammer Attacks

April 15, 2021
NikolaNews

NikolaNews.com is an online News Portal which aims to share news about blockchain, AI, Big Data, and Data Privacy and more!

What’s New Here?

  • Three Privacy Preserving Machine Learning Techniques Solving This Decade’s Most Important Issue April 15, 2021
  • 5 Ways Conversational AI is Shaping the Future of Learning | by Aurosikha Priyadarshini | Apr, 2021 April 15, 2021
  • Marketing Automation Technology for Revenue & Growth April 15, 2021
  • A brief intro to Red Hat OpenShift for Node.js developers – IBM Developer April 15, 2021

Subscribe to get more!

© 2019 NikolaNews.com - Global Tech Updates

No Result
View All Result
  • AI Development
    • Artificial Intelligence
    • Machine Learning
    • Neural Networks
    • Learn to Code
  • Data
    • Blockchain
    • Big Data
    • Data Science
  • IT Security
    • Internet Privacy
    • Internet Security
  • Marketing
    • Digital Marketing
    • Marketing Technology
  • Technology Companies
  • Crypto News

© 2019 NikolaNews.com - Global Tech Updates