Vending Machine for Stray Cats & Dogs | Study Pack of HUSKYLENS for micro:bit 04

0 4727 Medium

Lesson 4: Vending Machine for Stray Cats & Dogs with an AI Machine Vision Sensor

Introduction

We may often see abandoned cats or dogs wandering around the city and searching for food in trash bins. As animal lovers, we feel sad that these little guys are forced to suffer for whatever reason. All animals deserve to be loved and nurtured. Can we do anything for them? If there is a feeding machine that determines whether it is a cat or a puppy in front and feed it with corresponding food, just like a vending machine in the stray animal world, wouldn't it be great? Let's use AI machine vision sensor HUSKYLENS,along with micro:bit, to build a object recognition AI camera feeding apparatus!

projectImage

In this project, we will use the object recognition function of AI machine vision sensor HUSKYLENS to distinguish cats and dogs through machine learning. Then, a micro:bit will be utilized to process the results and control the servo, enabling the opening of the valve and the dispensation of appropriate food to cats and dogs.

Learning Objectives

1. Learn the working principle and application field of object recognition.

2. Learn to use the object recognition function.

3. Use AI machine vision sensor HUSKYLENS to make a vending machine for stray animals

Preparation

projectImage

Learning Content

The object recognition function of AI machine vision sensor HUSKYLENS belongs to image recognition. Image recognition technology is an important field of artificial intelligence. It refers to the ability of a computer powered camera to identify and detect objects or features in a digital image or video. In this project we will use the image recognition of AI machine vision sensor HUSKYLENS to distinguish and recognize cats and dogs.

Working Principle and Application Field of Image Recognition

 

1. What is image recognition

Image recognition, a practical application of deep learning algorithm, refers to the processing, analysis, and understanding of images by computer so as to recognize targets and objects in different modes. It is divided into face recognition and product recognition currently. The former is mainly used in security checks, identification, and mobile payment, while the latter can be usually found in the process of commodity circulation, especially unmanned shop, intelligent retail counter, and other unmanned sales fields.

projectImage
2. Working principle

Four steps for traditional image recognition:

projectImage

Image Capture: capture the image by the camera, and prepare for later recognition.

Image Preprocessing: analyze and process the images through a series of algorithms.

Feature Extraction: according to the information processed in the previous step, extract the key information, such as color, outline, etc.

Image Recognition: compare the information extracted with the sample base, the AI machine vision sensor HUSKYLENS sensor image recognition includes a built-in sample library and it can be enriched by learning.

3. Similarities and differences between image recognition and other recognition:

We have already learned a lot of functions about camera recognition, such as face recognition and color recognition. What are the differences between them?

We can infer that face recognition, as one of the image recognition, is specifically used for distinguishing human faces. Imagine this scenario: when a group of people passes the camera, the name of each person can be “called out” if the information has been input in advance, while the image recognition can only offer the result human, human, human.... because it can only recognize objects but not distinguish individuals.

projectImage

We may find image recognition similar to object tracking. Both of them are function of recognition, but technically, object tracking can only learn and track one object, while image recognition can recognize multiple objects because object tracking learns an object from different angles so that accurate tracking can be achieved while image recognition only learns with only one side and recognition cannot be achieved once from another angle.

Color recognition and QR code recognition are easy to distinguish since they are both specific function-oriented.

4. Application Scenarios

Biomedicine:

Image recognition is widely used in modern medicine because of its explicitness, non-invasive, safe, and convenience, especially in clinical diagnosis and pathological research. For example, during the period of COVID-19, AI is deployed to quickly review the CT of the patients.

Remote Sensing Image Recognition

Aerial remote sensing and satellite remote sensing images are usually processed with image recognition to extract useful information. This technology is mainly used for terrain and geological exploration, forest, water, marine, agricultural and other resource surveys, disaster prediction, environmental pollution monitoring, meteorological satellite cloud image processing, and ground military target recognition.

Demonstration of AI Machine Vision Sensor HUSKYLENS Object Recognition

This function is able to recognize what the object is and track it. 20 objects are supported: airplane, bicycle, bird, boat, bottle, bus, car, cat, chair, cow, dining table, dog, horse, motorbike, person, potted plant, sheep, sofa, train, television. The default setting is to frame and recognize one object. In this chapter, we are going to frame and recognize multiple objects as an example.

1. Operating Setting-Learn Multiple Objects

Dial the “function button” to the left or right until “face recognition” is displayed at the top of the screen. Long press the “function button” to enter the parameter setting interface of the submenu of object recognition.

Dial the “function button” to the left or right, select the “learn multiple”. Then dial to the right and turn on the “Learn Multiple” switch, that is, progress bar turns blue and the square icon on the progress bar moves to the right. After that, short press the “function button” to confirm this parameter.

projectImage

Dial the “function button” to the left and select “save & return”, short press “function button”. It will display “Do you want to save the parameters?”, and “yes” is the default one. Short press the “function button”, the data will be saved, and it will automatically return to the object recognition mode.

2. Learning and Recognition

1. Detecting Object

When detecting objects, AI machine vision sensor HUSKYLENS will automatically recognize them, and the object will be displayed by the white frame with its name on the screen. At present, only 20 built-in objects can be recognized.

projectImage

2. Marking Object

Point the “+” symbol at the object, then short press the “learning button”. When pressing, the color of the frame changes from white to blue, and the name of the object and its ID number will appear on the screen. There will be a notice:”Click again to continue! Click other buttons to finish”. Please short press the "learning button" before the countdown ends if you want to learn other objects. If not, short press the "function button" before the countdown ends, or just do not press any button to let the countdown ends.

The ID number is related to the order of marking objects. For example: the ID will be displayed as “ID1”, “ID2”, “ID3” in order, and different objects are matched with different colored frames.

projectImage

3. Object Recognition

When encountering the learned objects, they will be selected by colorful frames, and the name and ID number will be displayed. It also supports simultaneous recognition of multiple types of objects, such as recognizing bottles and birds at the same time.

projectImage

Tip: This function cannot distinguish the differences between objects of the same category. For example, it can only recognize that this is a cat, but cannot recognize what kind of cat it is.

AI Vision Project Practice

We will complete the task in two steps. First, we will learn to use the image recognition function of AI machine vision sensor HUSKYLENS and output the recognized results. Then, distribute the corresponding food according to the result.

Task 1: Distinguish cats and dogs

In this step, we need to enable the AI machine vision sensor HUSKYLENS camera to recognize and distinguish cats and dogs and give feedback so that we can release the corresponding food in the next step.

Task 2: Add the function of dispensing food

In this step, you need to add the function of dispensing food based on the previous step, and make the corresponding structure.

Task1: Distinguish cats and dogs

Hardware Connection
projectImage

AI Vision Program Design

Function instruction:

Here we need to let the AI machine vision sensor HUSKYLENS sensor learn the images of cats and dogs, and output the result after recognition.

Tip: Turn on the Learn Multiple function in advance.

projectImage

Flowchart Analysis

projectImage

The MakeCode Sample Program

projectImage

Makecode Sample Program link : https://makecode.microbit.org/_EK2htTXW1U00

AI Vision Project Operating Effect

When a cat is recognized in the AI machine vision sensor HUSKYLENS sensor, pattern for“cat” will be displayed on micro:bit matrix, while “dog” pattern is displayed for dogs.

projectImage

Task2: Add the Function of Dispensing Food

Hardware Connection

projectImage

AI Vision Program Design

Function instruction:

Through the rotation angle of the servo, it simulates the action of food delivery. Since cats and dogs have different food intakes, different delays need to be set to control the food dispensing.

Flowchart Analysis

projectImage

The MakeCode Sample Program

projectImage
projectImage

Makecode Sample Program link https://makecode.microbit.org/_W5pA5eUsH2Ay

 

AI Vision Project Operating Effect

When a cat is recognized to be approaching, the micro:bit matrix screen will display “cat”pattern, and the cat food will be released. When completed, a heart image will be displayed. When a dog is recognized to be approaching, the matrix screen displays “dog” pattern and the dog food will be released. And also a heart will be displayed when done.

Question:

Although AI machine vision sensor HUSKYLENS can distinguish between cats and dogs, the program can also perform corresponding food dispensing operations, but if some cats and dogs always appear within the recognizable range of AI machine vision sensor HUSKYLENS, the automatic feeding machine will always release food. How can we solve this problem in the program?

Project Review

We use AI machine vision sensor HUSKYLENS to complete a stray vending machine step by step. It is not only good news for stray animals, but also convenient for good-hearted people to add food independently, donate their love to help them.

Project Development

After completing the vending machine, if you want to help more abandoned animals, can you add a statistical function to record the number of cats and dogs that come to the feeding machine to eat every day, so that the food can be rationed more reasonably.

License
All Rights
Reserved
licensBg
0