色塊追蹤與線條追蹤

加入KOI 2庫

from future import *
from koi2 import KOI2

初始化KOI 2

koi = KOI2(tx, rx)

初次化KOI 2連接。

參數:

tx: TX 針腳,Robotbit EDU使用P2

rx: RX 針腳,Robotbit EDU使用P12

選擇線條追蹤模式

koi.setModel(16)

選擇線條追蹤模式

選擇目標顏色

koi.colorSwitch(color)

參數:

color: 顏色

color
代表

0

紅色

1

2

Blue

3

Yellow

9

自定義(需要校正)

校正自定義顏色

校正自定義顏色

獲取色塊數據

獲取色塊數據

參數:

data: 數據類型

data
代表

0

X coordinates

1

Y coordinates

2

Width of blob

3

Height of blob

範例程式: 色塊追蹤

選擇線條追蹤模式

選擇線條追蹤模式

選擇目標顏色

參數:

color: 顏色

color
代表

0

紅色

1

2

Blue

3

Yellow

9

自定義(需要校正)

校正自定義顏色

校正自定義顏色

獲取線條數據

獲取線條數據

參數:

data: The type of data to return.

data
代表

0

X1 coordinates

1

Y1 coordinates

2

X2 coordinates

3

Y2

範例程式: 線條追蹤

Last updated