cocube_sengo2
import cocube_sengo2 as sg2
Initialization
sg2.init()
sg2.reset()
sg2.change_algo("AprilTag")
Notes:
init()waits for the camera to become ready, up to about5sreset()resets all algorithms- most read functions require you to switch to the matching algorithm first
Supported algorithms
"Color Recog""Blob Detect""AprilTag""Line Detect""Deep Learning""Card Recog""Face Recog""Obj20Class""QRcode""Motion Detect"
Color recognition
sg2.change_algo("Color Recog")
sg2.set_color_area(x, y, w, h)
sg2.read_color()
sg2.get_color_rgb("R")
Blob detection
sg2.change_algo("Blob Detect")
sg2.set_blob_property("red", w, h)
sg2.read_blob()
sg2.get_blob("x")
AprilTag
sg2.change_algo("AprilTag")
sg2.set_apriltag_type("36H11")
sg2.read_apriltag()
sg2.get_apriltag("x")
Available families:
16H525H936H11
Line following
sg2.change_algo("Line Detect")
sg2.get_line("degree")
sg2.get_line("x2")
Deep learning
sg2.change_algo("Deep Learning")
sg2.record_learning(id)
sg2.delete_learning(id)
sg2.get_learning_id()
Notes:
- the valid range for
record_learning(id)anddelete_learning(id)is1~15 get_learning_id()returns the currently recognized learned category ID
Card recognition
sg2.change_algo("Card Recog")
sg2.read_card()
sg2.get_card("x")
Sengo2 has a larger card set than Sengo1. Common examples include:
forwardturn_leftturn_rightturn_aroundparkgreen_lightred_lightspeed_40speed_60speed_80
Face, 20-class objects, QR code, and motion detection
sg2.change_algo("Face Recog")
sg2.record_face(id)
sg2.delete_face(id)
sg2.get_face_id()
sg2.change_algo("Obj20Class")
sg2.read_obj20()
sg2.get_obj20("x")
sg2.change_algo("QRcode")
sg2.read_qrcode()
sg2.change_algo("Motion Detect")
sg2.get_motion("x")
Notes:
- the valid range for
record_face(id)anddelete_face(id)is1~10 Face Recogonly returns the face ID directly; it does not exposex / y / w / hbounding boxesread_obj20()returns one of 20 object names, such asperson,car, orcatread_qrcode()returns the QR code string contentget_motion("x" / "y" / "w" / "h")returns the motion area
Notes
set_apriltag_type(...)only accepts16H5,25H9, and36H11- when no clear color is recognized, Sengo2 color recognition may return
unknown
Minimum example
import time
import cocube_sengo2 as sg2
sg2.init()
sg2.change_algo("Color Recog")
while True:
color_name = sg2.read_color()
if color_name:
print(color_name)
time.sleep_ms(100)