Welcome to Tiny:bit Pro repository
2.6 Learning and classification
2.6 Learning and classification
2.6 Learning and classification1. Learning Objectives2. Preparation before class3. Programming Methods4. Blocks5. Code6. Download code7. Experimental Phenomena
1. Learning Objectives
In this lesson, we learn how to make the k210 independent learning classification after the Micro:bit led dot matrix display classification serial number, independent learning can learn 3 different objects.
Note: It is recommended to use different color objects.
2. Preparation before class
- Remove the TF card from the k210 vision module and insert it into the card reader.
- Plug the card reader into the computer, and wait for the computer to recognize the USB disk.
- Then, enter the TF card U disk. You will see following content.
- Go to the k210 folder, find the 2.6_3.5_self_learning.py file from the folder and copy it to the root directory.
Delete the original main.py file.
Then, re-name the 2.6_3.5_self_learning.py file as the main.py file.
- After re-name, pull out the card reader, remove the TF card and insert it back into the k210 vision module.
3. Programming Methods
Online programming: first copy this URL https://makecode.microbit. and enter the online programming interface.
Copy the package URL: https://github.com/YahboomTechnology/K210-Module.git to the input field, click confirm to add the package, after that you can use the blocks of K210 vision module package.
4. Blocks
5. Code
6. Download code
Connect the Micro:bit board to the computer via Micro USB cable, the computer will pop up a USB stick.
Then, select the microbit-selflearn.hex file and right click to send it to the Micro:bit U disk.
Wait until sending is complete and unplug the Micro:bit USB cable. Plug the Micro:bit board into the car.
7. Experimental Phenomena
After starting the car, wait for the screen to display Self Learning Demo.
After the camera screen appears, find three different objects and train three different objects separately.
After the screen display prompts to press to enter the next state, long press to restart. At this time, press the K1 button in the upper right corner to enter the next state.
Start training the first object. Press the K1 button in the upper right corner to go to the next step and start capturing the object picture material.
Put the first object to be recognized into the visible range of the camera, you can see that Class 1: #P1 is displayed in the lower left corner of the screen, and if you press the K1 button, the first material picture of Class 1 will be recorded. Where Class denotes the category serial number and P denotes the picture serial number.
Shift the shooting angle slightly and press the BOOT key again to capture the second material picture. When five images have been captured, Category 1 capture is complete.
Next, enter the acquisition process of category 2, press the BOOT button to start the acquisition of category 2 material images, the steps are the same as the acquisition of category 1.
After category 2 has collected five material images, go to category 3 to collect five material images.
It automatically enters the classification state after finishing the collection. The display of Classificatiion in the middle of the screen indicates that it has entered the classification state, and the prompt disappears automatically by pressing the K1 button once more.
At this time, the camera will shoot one of the three categories just trained, the lower left corner of the screen will display the corresponding category serial number and score, at this time, the led dot matrix of the microbit board displays the classification serial number.
When no object is recognized, the led dot matrix will show -1, which means no object is recognized. If the recognition is not good, or the image acquisition is wrong, you can press reset, or long press the K1 button to start again.