AI by M5 STICK
AI by M5 STICK
2023 MARCH
SATIT PIM
Prerequisite Hardware &Program
• M5 STICKV AI.CAMERA
• EasyLoader v5.1.2
• MaxiPy IDE
M5 STICKV AI.CAMERA
• Face recognition/detection
• Object detection/classification
• Obtaining size and coordinates of the target in real time
• Obtaining a type of detected target in real time
• Shape recognition
• Game simulator
img = image.Image("/sd/pic.bmp")
lcd.display(img)
img = image.Image()
img.draw_string(60, 100, "hello maixpy", scale=2)
lcd.display(img)
Example 4:Display the image captured by
the camera in real time
import sensor, lcd
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.run(1)
sensor.skip_frames()
lcd.init()
while(True):
lcd.display(sensor.snapshot())
ถ้าไม่พบรู ปเรี ยลไทม์ คลิ๊กที่ลูกศรนี้
Example : Display fps
import sensor
import image
import lcd
import time
clock = time.clock()
lcd.init()
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.run(1)
sensor.skip_frames(30)
while True:
clock.tick()
img = sensor.snapshot()
fps =clock.fps()
img.draw_string(2,2, ("%2.1ffps" %(fps)), color=(0,128,0),
scale=2)
lcd.display(img)
Example : Face Detection using M5StickV
import sensor
import image
import KPU as kpu
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.run(1)
task = kpu.load(0x300000)
anchor = (1.889, 2.5245, 2.9465, 3.94056, 3.99987, 5.3658,
5.155437, 6.92275, 6.718375, 9.01025)
a = kpu.init_yolo2(task, 0.5, 0.3, 5, anchor)
while(True):
img = sensor.snapshot()
code = kpu.run_yolo2(task, img)
if code:
for i in code:
print(i)
a = img.draw_rectangle(i.rect())
a = kpu.deinit(task)
• https://www.youtube.com/watch?v=1chWkfX9lpY