Custom Tracking Models

Import KOI 2 Library

from future import *
from koi2 import KOI2

Serial Initialization

koi = KOI2(tx, rx)

Initializes the serial connection to KOI.

Parameters:

tx: TX Pin, use P2 for Robotbit EDU

rx: RX Pin, use P12 for Robotbit EDU

Select Custom Tracking Mode

koi.setModel(3)

Sets the KOI mode to Custom Tracking.

Load Custom Tracking Model

koi.initCustomModel(name, anchor)
koi.initCustomModel('/sd/ballRGB.kmodel',[1.25,1.25,1.50,1.50,1.72,1.72,1.97,1.97,2.34,2.31]) #example for color balls model

Loads a custom model.

Parameters:

name: File name

anchor: A list containing the anchor values.

Get Item Class Coordinates

Returns coordinates for the detected custom class.

Parameters:

data: The type of data to return.

data
Meaning

0

X coordinates

1

Y coordinates

2

Width of item

3

Height of item

Get Item ID

Returns the name of the item ID.

Sample Code: Custom Tracking Model

Last updated