Detects changes in the current screen and determines whether or not there is movement of objects in the detection area.
from m5stack import *
from m5ui import *
from uiflow import *
import unit
setScreenColor(0x222222)
V_0 = unit.get(unit.V_FUNCTION, unit.PORTB)
motion = V_0.init(V_0.MOTION)
motion.setMotionDetectThreshold(0)
motion.setDetectMode(0)
while True:
if (motion.getMaxDiff()) >= 50:
print('Moved')
else:
print('Not Move')
wait_ms(2)
import unit
V_0 = unit.get(unit.V_FUNCTION, unit.PORTB)
motion = V_0.init(V_0.MOTION)
motion.setMotionDetectThreshold(0)
motion.setDetectMode(0)
motion.getRateOfDiff()
motion.getMaxDiff()
motion.setScanInterval(0, 0)
print(motion.getBoxNumber())
print(motion.getBoxDetail(1))
Set the tracking target and get the position information of the target object in the screen in real time.
from m5stack import *
from m5ui import *
from uiflow import *
import time
import unit
setScreenColor(0x222222)
V_0 = unit.get(unit.V_FUNCTION, unit.PORTB)
target = V_0.init(V_0.TARGET_TRACK)
target.setTrackAreaCoordinate(50, 50, 30, 30)
while True:
print((str('X :') + str(((str((target.getBoxDetail())[0]) + str(((str('Y :') + str((target.getBoxDetail())[2])))))))))
wait(1)
wait_ms(2)
import unit
V_0 = unit.get(unit.V_FUNCTION, unit.PORTB)
target = V_0.init(V_0.TARGET_TRACK)
target.setTrackAreaCoordinate(50, 50, 30, 30)
target.getBoxDetail()
Set the LAB color threshold, track the target that meets the threshold in the screen, and obtain the position information of the target object in the screen in real time.
from m5stack import *
from m5ui import *
from uiflow import *
import unit
setScreenColor(0x222222)
V_0 = unit.get(unit.V_FUNCTION, unit.PORTB)
box_detail = None
color_track = V_0.init(V_0.COLOR_TRACK)
while True:
box_detail = color_track.getBoxDetail(1)
print((str('Box number: ') + str((color_track.getBoxNumber()))))
print((str('Box1 pixels changed: ') + str(box_detail[0])))
print((str('Box1 x: ') + str(box_detail[1])))
print((str('Box1 y: ') + str(box_detail[2])))
print((str('Box1 w: ') + str(box_detail[3])))
print((str('Box1 h: ') + str(box_detail[4])))
wait_ms(2)
import unit
V_0 = unit.get(unit.V_FUNCTION, unit.PORTB)
color_track = V_0.init(V_0.COLOR_TRACK)
color_track.setTrackColorByLAB(0, 0, 0, 0, 0, 0)
color_track.setScanInterval(0, 0)
color_track.setBoxMergeThreshold(0)
color_track.setBoxWidthThreshold(0, 0)
print(color_track.getBoxNumber())
print(color_track.getBoxDetail(1))
Recognize the face information in the screen, and return the number of recognition, object coordinates, confidence rate.
from m5stack import *
from m5ui import *
from uiflow import *
import unit
setScreenColor(0x222222)
V_0 = unit.get(unit.V_FUNCTION, unit.PORTB)
data_detail = None
face = V_0.init(V_0.FACE_DETECT)
while True:
print((str('FaceNumber: ') + str((face.getFaceNumber()))))
data_detail = face.getFaceDetail(1)
print((str('Face1 value: ') + str(((str(("%.2f"%((data_detail[0] * 100)))) + str('%'))))))
print((str('Face1 X: ') + str(data_detail[1])))
print((str('Face1 Y: ') + str(data_detail[2])))
print((str('Face1 W: ') + str(data_detail[3])))
print((str('Face1 H: ') + str(data_detail[4])))
wait_ms(2)
import unit
V_0 = unit.get(unit.V_FUNCTION, unit.PORTB)
face = V_0.init(V_0.FACE_DETECT)
face.getFaceNumber()
face.getFaceDetail(1)
Recognizes the QR code on the screen, and returns the result, as well as the version. Use firmware Find code
from m5stack import *
from m5ui import *
from uiflow import *
import unit
setScreenColor(0x222222)
V_1 = unit.get(unit.V_FUNCTION, unit.PORTB)
qr = V_1.init(V_1.QR_CODE)
while True:
print((str('QRcode version: ') + str((qr.getQRversion()))))
print((str('Code text: ') + str((qr.getQRtext()))))
wait_ms(2)
import unit
V_1 = unit.get(unit.V_FUNCTION, unit.PORTB)
qr = V_1.init(V_1.QR_CODE)
qr.getQRtext()
qr.getQRversion()
Identify the Apriltag code in the screen (only Tag36H11 type is supported), and get the offset of its position. Use firmware Find code
from m5stack import *
from m5ui import *
from uiflow import *
import unit
setScreenColor(0x222222)
V_1 = unit.get(unit.V_FUNCTION, unit.PORTB)
tag = V_1.init(V_1.APRILTAG)
while True:
print((str('AprilTag location: ') + str((tag.getAprilTagcodeLocation()))))
print((str('AprilTag rotation: ') + str((tag.getAprilTagcodeRotation()))))
print((str('AprilTag translation: ') + str((tag.getAprilTagcodeTranslation()))))
wait_ms(2)
import unit
V_1 = unit.get(unit.V_FUNCTION, unit.PORTB)
tag = V_1.init(V_1.APRILTAG)
tag.getAprilTagcodeLocation()
tag.getAprilTagcodeRotation()
tag.getAprilTagcodeTranslation()
Recognizes barcodes on the screen and returns the result, as well as the version. Using firmware Find code
from m5stack import *
from m5ui import *
from uiflow import *
import unit
setScreenColor(0x222222)
V_1 = unit.get(unit.V_FUNCTION, unit.PORTB)
bar = V_1.init(V_1.BARCODE)
while True:
print((str('Code text: ') + str((bar.getBARcodeText()))))
print((str('Code type: ') + str((bar.getBARcodeRotation()))))
print((str('Code rotation: ') + str((bar.getBARcodeType()))))
print((str('Code location: ') + str((bar.getBARcodeLocation()))))
wait_ms(2)
import unit
V_1 = unit.get(unit.V_FUNCTION, unit.PORTB)
bar = V_1.init(V_1.BARCODE)
bar.getBARcodeLocation()
bar.getBARcodeRotation()
bar.getBARcodeText()
bar.getBARcodeType()
Recognizes the Datamatrix code in the screen, and returns the recognition result, as well as the code rotation angle and coordinate data. Use firmware Find code
.
from m5stack import *
from m5ui import *
from uiflow import *
import unit
setScreenColor(0x222222)
V_1 = unit.get(unit.V_FUNCTION, unit.PORTB)
dm = V_1.init(V_1.DATAMATRIX)
while True:
print((str('DM code rotation: ') + str((dm.getDMcodeRotation()))))
print((str('DM code location: ') + str((dm.getDMcodeLocation()))))
print((str('DM code text: ') + str((dm.getDMcodeText()))))
wait_ms(2)
import unit
V_1 = unit.get(unit.V_FUNCTION, unit.PORTB)
dm = V_1.init(V_1.DATAMATRIX)
dm.getDMcodeLocation()
dm.getDMcodeRotation()
dm.getDMcodeText()
Detects a line of the specified color in the screen and returns the offset angle.
from m5stack import *
from m5ui import *
from uiflow import *
import unit
setScreenColor(0x222222)
V_1 = unit.get(unit.V_FUNCTION, unit.PORTB)
line_tracker = V_1.init(V_1.LINE_TRACKER)
while True:
print((str('Line angle') + str((line_tracker.getAngle()))))
wait_ms(2)
import unit
V_1 = unit.get(unit.V_FUNCTION, unit.PORTB)
line_tracker = V_1.init(V_1.LINE_TRACKER)
line_tracker.getAngle()
line_tracker.setLineAreaWeight(0, 0, 0)
line_tracker.setLineColorByLAB(0, 0, 0, 0, 0, 0)
Detects the tag card in the screen and returns the binary sequence. Note: Only the fixed label card format is recognized.
from m5stack import *
from m5ui import *
from uiflow import *
import unit
setScreenColor(0x222222)
V_1 = unit.get(unit.V_FUNCTION, unit.PORTB)
tag_reader = V_1.init(V_1.TAG_READER)
while True:
print((str('Total number: ') + str((tag_reader.getTotalNumber()))))
print((str('Tag location: ') + str((tag_reader.getTagLocation(number=0)))))
print((str('Code: ') + str((tag_reader.getCode(number=0)))))
print((str('Binstr: ') + str((tag_reader.getBinstr(number=0)))))
wait_ms(2)
import unit
V_1 = unit.get(unit.V_FUNCTION, unit.PORTB)
tag_reader = V_1.init(V_1.TAG_READER)
tag_reader.getTotalNumber()
tag_reader.getBinstr(number=0)
tag_reader.getCode(number=0)
tag_reader.getTagLocation(number=0)