KOI MicroPython API
Please refer to this page on how to utilize the various functions of the KOI using micropython.
Importing KOI library
Basics
LCD Orientation
Changes LCD orientation.
0 for front facing, 1 for back facing.
Drawing Strings
Draws a string on the LCD.
X, Y: Coordinates represent top left corner of string.
String: String.
Delay: Text duration.
Taking and showing pictures
Taking and showing pictures.
Getting button values
Obtains button values.
Returns 1 when pressed, 0 when not pressed.
Sample Program
Image Classifier
Initiate Classifier
Initiates the classifier.
Feature extraction
Extract features and add tag.
tag: object name, maximum 40 items, 40 pictures
Image Classifying
Classify the image, returns tag.
Classifier Event Triggers
Triggers an event on classification.
Saving and Loading Classifier Models
Save or load classifier models.
Sample Program
Face Detection
Load Face Model
Load face model.
Track face
Tracks the face, returns a list.
Sample Program
Geometric Shape Tracking
Track Lines
Find lines, returns a list.
Track Circles
Find circles, returns a list.
threshold: adjust this value to adjust sensitivity, default is 4000.
Track Rectangles
Find rectangles, returns a list.
threshold: adjust this value to adjust sensitivity, default is 4000.
Sample Program
Color Blob Tracking
Calibrates Color
Calibrates color for tracking.
Finds Color Blob
Finds color blob, returns a list.
Finds Line
Finds line, returns a list.
Sample Program
Barcode and QR code Recognition
QR Code Recognition
Finds QR code, returns content of QR code.
Barcode Recognition
Finds Barcode, returns content of barcode.
AprilTag Recognition
Finds Apriltag, returns content of Apriltag.
Sample Program
Voice Recognition
Record and Play
Records and plays a wav file.
Calibrates Noise Level
Calibrates the noise level, mandatory before voice recognition.
Adds Voice Command
Adds a voice command.
Recognizes Voice Command
Recognizes and returns the command.
Saves Voice Model
Saves the voice model.
Loads Voice Model
Loads the voice model.
Sample Program
IoT
Connecting to WiFi
Connects to WiFi.
IP Address
Return IP address.
Connects to MQTT Broker.
Connects to MQTT Broker.
host: MQTT host address
Subscribes Topic
Subscribes a topic on MQTT.
topic: topic to subscribe
Publishes Message to Topic
Publishes a message to topic.
topic: topic to publish.
message: message to publish.
Reads MQTT message
Reads topic message.
topic: topic to read from, returns a list.
Sample Program
Face Recognition
Face Recognition
Runs face recognition once.(WiFi required)
Face Parameters
Returns result from face recognition.
parameter:
face_token: unique face token for each face
location: coordinates, size of face
gender: gender of person
expression: emotion of person
angle: tilt angle of face
mask: true if person is wearing a mask
age: age of person
Adding Faces to a Group
Adds a face to the face group.
Searching Faces from a Group
Searches a face from a group, returns name and confidence.
Sample Program
Q&A
KOI’s display is laggy.
Please enable the screen refresh.
KOI does not run the program I uploaded.
Please restart the KOI because it was still running the original main.py.
Can I connect other modules using the 4-Pin Port?
No, this port is for connecting to Micro:bit only.
KOI’s LCD is reversed.
Please use the LCD orientation command.
Last updated