Energy Harvest | Study Pack of HUSKYLENS for micro:bit 07

0 3068 Medium

Lesson7: Energy Harvest with an AI Machine Vision Sensor

Have you ever engaged with games that revolve around the concept of energy accumulation? These games often present an array of energy units, each bearing different values, ready for you to harness. The act of collecting energy not only amplifies your energy reservoir, but also offers the ability to transform the amassed energy.

Can you predict our next move?
The capabilities of the AI Machine Vision Sensor Huskylens are substantial. We're about to leverage the tag recognition feature of the AI Machine Vision Sensor, in conjunction with the micro:bit, to develop an intriguing energy collection mini-game!

 

projectImage

Learning Objectives

1. Learn the working principle of tag recognition.

2. Learn to use the tag recognition function of HuskyLens

3. Learn what a random number is

4. Use HuskyLens to make an energy harvest project

Preparation

projectImage

Learning Content

Principle of Tag Recognition

1. What is tag recognition?

Tag recognition refers to the technology of effective and standardized coding and recognition of items, which is the basics of informatization. With people's increasing awareness of health and safety, the food industry has increasingly higher requirements on the quality and safety of products (from raw materials, transportation, production, storage, traceability and management). Tag recognition also plays an important role in meeting the needs of companies for product tracking and tracing.

Tag recognition technology mainly includes barcode technology, IC card technology, radio-frequency recognition technology, optical symbol recognition technology, speech recognition technology, biometric recognition technology, remote sensing, robot intelligent perception and other technologies.

projectImage

2. What is AprilTag?

AprilTags is a visual reference system from a UMich project team for AR, robotics and camera calibration. The tag acts as a barcode, storing a small amount of information (tag ID), while also providing a simple and accurate 6D (X, Y, Z, roll, pitch, yaw) pose estimation or the tag.

projectImage

3. Differences between AprilTag, barcode and QR code

Compared with barcode and QR code, AprilTag is more useful in machine vision, because it can calculate the accurate relative 3D location, direction, and ID through AprilTag. The 3D location in reality world is very useful for machine! AprilTag is usually used in fields like AR, robot, and camera calibration.

4. Working principle of tag recognition

Edge detection: find out the edge contour in the image.

projectImage

Quadrangle detection: find out the quadrangles in the contour

projectImage

Decoding: match and check the quadrangles.

projectImage

Demonstration of AI Machine Vision Sensor HUSKYLENS Tag Recognition Function

1. Tag detection

When HuskyLens detects a tag, the tag will be automatically selected by the white frame on the screen.

projectImage

2. Tag learning

Point the "+" symbol at the tag, long or short press the "Learning button" to complete the first tag learning. After releasing the "Learning button", the screen will display: "Press the button again to continue! Press other buttons to end. " To continue learning the next tag, press the "Learning button" before the countdown ends. If you no longer need to learn other tags, press the "Function button" before the countdown ends, or do not operate and wait for the end of the countdown.

projectImage

In this project, we are going to learn more tags, so press the "learning button" before the countdown ends, and then point the "+" in the center of the HuskyLens screen at the next tag that needs to be learned, short press or long press the "learning button" to complete the learning of the second tag. And so on.

The tag ID is consistent with the sequence of input, that is, the learned tags will be labeled as "tag: ID1", "tag: ID2", "tag: ID3", and so on, and the frame color corresponding to different tags is also different.

3. Tag recognition

When the HuskyLens encounters the learned tags, a colored frame with an ID will be automatically displayed on the screen. The size of the frame changes along with the size of the QR code tag and the frame will automatically track these QR code tags.

projectImage

AI Vision Project Practice

Next, the energy harvest game will be completed in two tasks. First, we must learn to use HuskyLens's tag recognition function, and output random numbers from the recognized results, and then determine whether the collected energy value can be used for energy synthesis by calculating the sum of the random numbers.

Task1: Generate energy

In the process of the game, the energy values collected are all randomly generated. Therefore, in this step, HuskyLens needs to recognize the AprilTag tag and generate a random number, also the collected energy value.

Task 2: Energy synthesis

Each AprilTag corresponds to a certain value. When the sum of all energy values is greater than 50, energy synthesis can be performed.

Task1: Generate energy

Hardware connection

projectImage

AI Vision Program Design

Function instruction:

The HuskyLens sensor needs to learn multiple AprilTag tags and be able to display random numbers from 0 to 9 on the micro:bit matrix screen after the recognition is successful.

projectImage

Flowchart Analysis

projectImage

The MakeCode Sample Program

projectImage

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

AI Vision Project Operating Effect

In this project, at least one AprilTag needs to be learned, as long as HuskyLens recognizes the learned AprilTag, it will generate a random number ranging from 0 to 9. As shown in the figure, the random numbers generated by the same AprilTag tag are not the same.

projectImage

Task2: Energy synthesis

Hardware connection

projectImage

AI Vision Program Design

Function instruction:

On the basis of the previous project, the function of displaying the sum of energy (Sum of energy) has been added. When the sum of energy>=50, energy synthesis is performed. Meanwhile, the function of re-collecting is also added. Press button A on the micro:bit to clear the display and initialize the energy value and the total energy points.

Flowchart Analysis

projectImage

The MakeCode Sample Program

projectImage

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

AI Vision Project Operating Effect

Every time HuskyLens successfully recognizes a learned AprilTag tag, a random number will be generated and showed on the micro:bit dot matrix screen, and the sum of the calculated random numbers will be displayed on the HuskyLens screen; when the sum of random numbers is greater than 50, energy synthesis is performed, a "heart-shaped" pattern shows on the micro:bit, and the buzzer plays music "power up"; press button A to clear all the displays and start a new round of energy harvesting.

projectImage

Project Review

This project mainly uses the tag recognition function of HUSKYLENNS. Each time HuskyLens recognizes a learned tag, a random number ranging from 0~9 will be generated, then judge the sum of the random number and perform corresponding operations. Do you know where random number is used in daily life?

Project Development

The energy harvest is just a little game, it is funny when playing with friends. Now, call on your friends and have a competition with them!

Game rules:

1. The one using the tag recognition function of HuskyLens fewer times wins.

2. The one spending less time wins when the number of times using HuskyLens are the same.

projectImage
License
All Rights
Reserved
licensBg
0