Built-in Tracking Models
Last updated
Last updated
from future import *
from koi2 import KOI2
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
koi.setModel(1)
Sets the KOI mode to Road Sign Tracking.
koi.xywh[0]
Returns coordinates for the detected road sign.
Parameters:
data: The type of data to return.
0
X coordinates
1
Y coordinates
2
Width of road sign
3
Height of road sign
koi.strVal
Returns the name of the road sign.
Values Returned: U-Turn, forward, left, right, limit-30, stop, tunnel
from future import *
from koi2 import KOI2
koi = KOI2('P2', 'P12')
koi.setModel(1)
sleep(15)
koi.direction(2)
koi.mirror(0)
screen.sync = 0
while True:
koi.read_from_uart()
screen.fill((0, 0, 0))
screen.text(koi.strVal,5,10,2,(255, 255, 255))
screen.text(koi.xywh[0],5,30,2,(255, 255, 255))
screen.text(koi.xywh[1],5,50,2,(255, 255, 255))
screen.text(koi.xywh[2],5,70,2,(255, 255, 255))
screen.text(koi.xywh[3],5,90,2,(255, 255, 255))
screen.refresh()
koi.setModel(2)
Sets the KOI mode to Common Items Tracking.
koi.xywh[0]
Returns coordinates for the detected item.
Parameters:
data: The type of data to return.
0
X coordinates
1
Y coordinates
2
Width of item
3
Height of item
koi.strVal
Returns the name of the item.
Values Returned: aeroplane, bicycle, bird, boat, bottle, bus, car, cat, chair, cow, diningtable, dog, horse, motorbike, person, pottedplant, sheep, sofa, train, tvmonitor
from future import *
from koi2 import KOI2
koi = KOI2('P2', 'P12')
koi.setModel(2)
sleep(15)
koi.direction(2)
koi.mirror(0)
screen.sync = 0
while True:
koi.read_from_uart()
screen.fill((0, 0, 0))
screen.text(koi.strVal,5,10,2,(255, 255, 255))
screen.text(koi.xywh[0],5,30,2,(255, 255, 255))
screen.text(koi.xywh[1],5,50,2,(255, 255, 255))
screen.text(koi.xywh[2],5,70,2,(255, 255, 255))
screen.text(koi.xywh[3],5,90,2,(255, 255, 255))
screen.refresh()
koi.setModel(6)
Sets the KOI mode to Alphabet Tracking.
koi.xywh[0]
Returns coordinates for the detected alphabet.
Parameters:
data: The type of data to return.
0
X coordinates
1
Y coordinates
2
Width of alphabet
3
Height of alphabet
koi.strVal
Returns the name of the alphabet.
Values Returned: A, B, C, D, E, F
from future import *
from koi2 import KOI2
koi = KOI2('P2', 'P12')
koi.setModel(6)
sleep(15)
koi.direction(2)
koi.mirror(0)
screen.sync = 0
while True:
koi.read_from_uart()
screen.fill((0, 0, 0))
screen.text(koi.strVal,5,10,2,(255, 255, 255))
screen.text(koi.xywh[0],5,30,2,(255, 255, 255))
screen.text(koi.xywh[1],5,50,2,(255, 255, 255))
screen.text(koi.xywh[2],5,70,2,(255, 255, 255))
screen.text(koi.xywh[3],5,90,2,(255, 255, 255))
screen.refresh()
koi.setModel(4)
Sets the KOI mode to Numbers Tracking.
koi.xywh[0]
Returns coordinates for the detected number.
Parameters:
data: The type of data to return.
0
X coordinates
1
Y coordinates
2
Width of number
3
Height of number
koi.numberVal
Returns the name of the number.
Values Returned: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
from future import *
from koi2 import KOI2
koi = KOI2('P2', 'P12')
koi.setModel(4)
sleep(15)
koi.direction(2)
koi.mirror(0)
screen.sync = 0
while True:
koi.read_from_uart()
screen.fill((0, 0, 0))
screen.text(koi.numberVal,5,10,2,(255, 255, 255))
screen.text(koi.xywh[0],5,30,2,(255, 255, 255))
screen.text(koi.xywh[1],5,50,2,(255, 255, 255))
screen.text(koi.xywh[2],5,70,2,(255, 255, 255))
screen.text(koi.xywh[3],5,90,2,(255, 255, 255))
screen.refresh()