检测当面画面的变化情况,判断检测区域内的物体是否存在运动。
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))
设置追踪目标,实时获取目标对象处于画面中位置信息。
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()
设置LAB颜色阈值,追踪画面中符合阈值目标,并实时获取目标对象处于画面中位置信息。
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))
识别画面中的人脸信息,并返回识别个数,对象坐标,置信率。
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)
识别画面中的二维码,并返回识别结果,以及版本。使用固件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()
识别画面中的Apriltag码(仅支持Tag36H11类型),并获取其位置的偏移。使用固件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()
识别画面中的条形码,并返回识别结果,以及版本。使用固件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()
识别画面中的Datamatrix码,并返回识别结果,以及码旋转角度,坐标数据。使用固件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()
检测画面中指定的颜色线条,并返回偏移角度。
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)
检测画面中的标签卡,并返回二进制序列。注:仅识别固定标签卡格式
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)