Source code for recording data to train color detection machine learning models on EV3 and Spike Prime kits
- Follow the PyBricks installation guide here
- Install VS Code and the ev3Dev extension
- Clone this repository in VS Code
- Create a new python Spike Prime project
- Clone this repository to your computer
- Copy the contents of main.py to the project
The spike prime app console is unable to process much data, so you may need to collect data in smaller increments of ~20 readings (I spent an entire night trying to circumvent this limitation, there is no official solution)
- Remove the pybricks shebang if you are using spike prime
#!/usr/bin/env pybricks-micropython
- edit
sensorsToCheck
to include the ones you use - edit
trainableColors
to include color options
- Run the project
- Check the EV3 screen or Spike Prime console for instructions
- Place your color sensors on the first color
- move through the options to select the first color you want to train
- move your robot around slightly while still staying on the color
- press the stop button once you've got enough data (~1000 entries per color which can be split over multiple readings at multiple times of day and if possible multiple boards)
- Copy the stuff in between the square brackets into a file with the format
colorname.json
ie.
[{"id": "Port.S1", "reflectivity": 13, "truth": "Black", "blue": 10, "classification": "Black", "ambient": -73, "red": 12, "green": 13}, {"id": "Port.S1", "reflectivity": 12, "truth": "Black", "blue": 9, "classification": "Black", "ambient": 1, "red": 11, "green": 12},...]
- Repeat with all your colors
Upload all your .json files to a google drive folder and open this Google Colab instance
You can redistribute, reproduce, modify, and sell this software as long as you also use the BSL license and give some credit