Welcome to Tiny:bit Pro repository
3.4 Object detection
3.4 Object detection
3.4 Object detection1. Learning objectives2. Preparation before the class3. Programming Methods4. Blocks5. Assortment blocks6. Download code7. Experimental phenomena
1. Learning objectives
In this lesson, we will realize how to let the K210 vision module recognize specific objects. There are 20 kinds of objects, namely: "airplane", "bicycle", "bird", "ship", "bottle", "bus","car", "cat", "chair", "cow", "dining table", "dog", "horse", "motorcycle", "person", "potted plant", "sheep", "sofa", "Train", "TV screen".
Here we choose 5 kinds of objects as examples. When a bird is recognized, music will be played; When a car is recognized, the searchlights will light up in color order; When the chair is recognized, the image of the chair will be displayed on the microbit board; When a motorcycle is recognized, the car will move forward for one second, backward for one second, turn left for one second, and turn right for one second; When a person is recognized and the car is within 20cm of the person, the car will move back for two seconds, then stop.
2. Preparation before the 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.
- The computer recognises it and enters into the TF card.
- Go to the k210 folder, find the 2.5_3.4_object_detect.py file from the folder and copy it to the root directory.
- Delete the original main.py file.
Then, re-name the 2.5_3.4_object_detect.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.
Click Extension, copy the package URL: https://github.com/YahboomTechnology/K210-Module.git to the input field, click Confirm to add package,
Click Extension again, copy the package URL: https://github.com/YahboomTechnology/Tiny-bitLib to the input field, click Confirm to add the package.
Finally you can use the K210 Vision Module package and Tinybit's building blocks.
4. Blocks
5. Assortment blocks
6. Download code
Connect the Micro:bit board to the computer via microusb cable, the computer will pop up a USB stick.
Then, select the k210_object_detect.hex code 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 the car starts, wait for the screen to display the camera image.
After the screen is displayed, point the camera at the object to be recognized.
When a car is recognized, the searchlights will light up in color order; When the chair is recognized, the image of the chair will be displayed on the microbit board; When a motorcycle is recognized, the car will move forward for one second, backward for one second, turn left for one second, and turn right for one second; When a person is recognized and the car is within 20cm of the person, the car will move back for two seconds and then stop.
