cocube_sengo1
import cocube_sengo1 as sg1
Initialization
sg1.init()
sg1.reset()
sg1.change_algo("Card Recog")
Notes:
init()waits for the camera to become ready, up to about5sreset()resets all algorithm states- before most read functions, you should call
change_algo(...)first
Supported algorithms
"Color Recog""Blob Detect""Ball Detect""Line Detect""Card Recog""Face Recog""QRcode"
Color recognition
sg1.change_algo("Color Recog")
sg1.set_color_area(x, y, w, h)
sg1.read_color()
sg1.get_color_rgb("R")
Returned color names include:
black, white, red, green, blue, yellow
set_color_area(x, y, w, h) also checks boundaries, so the area cannot exceed the image range.
Blob detection
sg1.change_algo("Blob Detect")
sg1.set_blob_property("red", w, h)
sg1.read_blob()
sg1.get_blob("x")
sg1.get_blob("y")
sg1.get_blob("w")
sg1.get_blob("h")
Ball detection
sg1.change_algo("Ball Detect")
sg1.detect_ball()
sg1.get_ball("x")
This is unique to Sengo1. Common return values include:
ping pongtennis ball
Line following
sg1.change_algo("Line Detect")
sg1.get_line("x1")
sg1.get_line("y1")
sg1.get_line("x2")
sg1.get_line("y2")
sg1.get_line("degree")
Card recognition
sg1.change_algo("Card Recog")
sg1.read_card()
sg1.get_card("x")
Common Sengo1 cards include:
forwardleftrightbackpark
Face recognition
sg1.change_algo("Face Recog")
sg1.record_face(id)
sg1.delete_face(id)
sg1.get_face_id()
sg1.get_face("x")
QR code
sg1.change_algo("QRcode")
sg1.read_qrcode()
sg1.get_qrcode("x")
read_qrcode() returns the QR code string content.
Notes
- if the current algorithm does not match, the read function throws an error directly and tells you to call
change_algo(...)first - the valid range for
record_face(id)anddelete_face(id)is1~10
Minimum example
import time
import cocube_sengo1 as sg1
sg1.init()
sg1.change_algo("Card Recog")
while True:
card = sg1.read_card()
if card:
print(card, sg1.get_card("w"))
time.sleep_ms(100)