Color Blob and Line Tracking

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 Color Blob Tracking Mode

koi.setModel(16)

Sets the KOI mode to Color Blob Tracking.

Set Color to Track

koi.colorSwitch(color)

Parameters:

color: Color to track

color
meaning

0

Red

1

Green

2

Blue

3

Yellow

9

Custom(requires calibration)

Calibrate Custom Color

Calibrates KOI to track a custom color.

Get Color Blob Data

Returns data for the tracked color blob.

Parameters:

data: The type of data to return.

data
Meaning

0

X coordinates

1

Y coordinates

2

Width of blob

3

Height of blob

Sample Program: Color Blob Tracking

Select Line Tracking Mode

Sets the KOI mode to Color Blob Tracking.

Set Color to Track

Parameters:

color: Color to track

color
meaning

0

Red

1

Green

2

Blue

3

Yellow

9

Custom(requires calibration)

Calibrate Custom Color

Calibrates KOI to track a custom color.

Get Line Data

Returns data for the tracked line.

Parameters:

data: The type of data to return.

data
Meaning

0

X1 coordinates

1

Y1 coordinates

2

X2 coordinates

3

Y2 coordinates

Sample Program: Line Tracking

Last updated