สำหรับ OpenMV firmware v5.0.0 · อิงจาก MicroPython v1.28 · สร้างเอกสาร 18 มิถุนายน ค.ศ. 2026

การมองเห็นของเครื่อง
ทำได้ง่าย

การตรวจจับใบหน้าแบบ live, การติดตาม AprilTag, การสแกน QR, และ YOLO ทั้งหมดบนอุปกรณ์ด้วย MicroPython ล้วนๆ ไม่มีคอมพิวเตอร์โฮสต์ ไม่มีคลาวด์

มีอะไรใหม่ อ่าน changelog ของ OpenMV firmware v5.0.0

Hello world

import csi
import time
import ml
from ml.postprocessing.ultralytics import YoloV8

csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.RGB565)
csi0.framesize(csi.VGA)
csi0.snapshot(time=2000)  # let AWB/AGC stabilize

# Built-in single-class person detector model.
model = ml.Model("/rom/yolov8n_192.tflite",
                 postprocess=YoloV8(threshold=0.4))
clock = time.clock()

while True:
    clock.tick()
    img = csi0.snapshot()
    # predict returns a list per class of ((x, y, w, h), score) tuples.
    for class_dets in model.predict([img]):
        for rect, score in class_dets:
            img.draw_rectangle(rect, color=(0, 255, 0))
    print(clock.fps(), "fps")

การติดตามบุคคลแบบ real-time

โมเดล YOLOv8 บนบอร์ดเป็นตัวตรวจจับบุคคลแบบ single-class — quantised แบบ int8 และติดมาใน ROM

โหลดจาก /rom/yolov8n_192.tflite — ไม่ต้องใช้ SD card หรือดาวน์โหลด
รันแบบ real-time บนบอร์ดที่มี NPU — OpenMV N6 และ AE3
นำโมเดล YOLOv8 ที่ฝึกบน Roboflow มาใช้งานและโหลดด้วยวิธีเดียวกัน
import csi
import math
import time

csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.RGB565)
csi0.framesize(csi.QVGA)
csi0.snapshot(time=2000)  # let AWB/AGC stabilize
csi0.auto_gain(False)
csi0.auto_whitebal(False)

clock = time.clock()

while True:
    clock.tick()
    img = csi0.snapshot()
    for tag in img.find_apriltags():
        img.draw_detection(tag, color1=(255, 0, 0), color2=(0, 255, 0))
        deg = math.degrees(tag.rotation)
        print("ID %d  rotation %.1f deg" % (tag.id, deg))
    print(clock.fps(), "fps")

ระบุตำแหน่งและระบุ AprilTags

AprilTags คือเครื่องหมาย fiducial 2 มิติ — ทนต่อการเบลอจากการเคลื่อนไหวและการบดบังบางส่วน และให้ท่าทาง 3 มิติครบถ้วน

ตัวตรวจจับในตัว — ไม่ต้องการไฟล์โมเดลหรือการฝึก
ส่งคืน ID พร้อม pose 6-DoF ครบถ้วน — การแปล x/y/z และการหมุน x/y/z
ใช้สำหรับการสอบเทียบหุ่นยนต์, เครื่องหมาย AR, และการระบุตำแหน่งในอาคาร
import csi
import time
import ml
from ml.postprocessing.mediapipe import BlazeFace

csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.RGB565)
csi0.framesize(csi.VGA)
csi0.window((400, 400))  # square window for best results
csi0.snapshot(time=2000)  # let AWB/AGC stabilize

model = ml.Model("/rom/blazeface_front_128.tflite",
                 postprocess=BlazeFace(threshold=0.4))
clock = time.clock()

while True:
    clock.tick()
    img = csi0.snapshot()
    for rect, score, keypoints in model.predict([img]):
        img.draw_rectangle(rect, color=(0, 0, 255))
        ml.utils.draw_keypoints(img, keypoints, color=(255, 0, 0))
    print(clock.fps(), "fps")

ตรวจจับใบหน้าด้วย BlazeFace

BlazeFace ของ Google เป็นตัวตรวจจับใบหน้า TensorFlow Lite แบบเบาที่ส่งคืน bounding boxes พร้อม landmarks 6 จุดต่อใบหน้า

โหลดจาก /rom/blazeface_front_128.tflite — pre-quantised ไม่ต้องดาวน์โหลด
จุดสำคัญหกจุดต่อใบหน้า: ดวงตา, จมูก, ปาก, และหู
ไม่มีปัญหาความเป็นส่วนตัว — เฟรมไม่ออกจากกล้อง
import csi
import time

csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.RGB565)
csi0.framesize(csi.QVGA)
csi0.snapshot(time=2000)  # let AWB/AGC stabilize
csi0.auto_gain(False)

clock = time.clock()

while True:
    clock.tick()
    img = csi0.snapshot()
    for code in img.find_qrcodes():
        img.draw_rectangle(code.rect, color=(255, 0, 0))
        print(code.payload)
    print(clock.fps(), "fps")

สแกน QR codes จากฟีดสด

ตัวถอดรหัส QR ในตัวรองรับโค้ดที่เอียง, บิดเบี้ยว, และถูกบดบังบางส่วน

ผลลัพธ์แต่ละรายการยังแสดงเวอร์ชัน, ระดับ ECC, และพิกัดมุม
โหมดข้อมูลตัวเลข, ตัวอักษรและตัวเลข, ไบนารี, และ Kanji
ส่งคืนเพย์โหลดที่ถอดรหัสแล้วเป็น Python string — พร้อมใช้งาน
import csi
import time

csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.RGB565)
csi0.framesize(csi.QVGA)
csi0.snapshot(time=2000)  # let AWB/AGC stabilize
csi0.auto_gain(False)
csi0.auto_whitebal(False)

# LAB thresholds: (L_min, L_max, A_min, A_max, B_min, B_max)
thresholds = [
    (30, 100, 15, 127, 15, 127),   # red
    (30, 100, -64, -8, -32, 32),   # green
]

clock = time.clock()

while True:
    clock.tick()
    img = csi0.snapshot()
    for blob in img.find_blobs(thresholds, pixels_threshold=200):
        img.draw_rectangle(blob.rect, color=(255, 0, 0))
        img.draw_cross((blob.cx, blob.cy))
    print(clock.fps(), "fps")

ค้นหาบลอบของสี

find_blobs ส่งคืนบริเวณพิกเซลที่เชื่อมต่อกันซึ่งตรงกับค่าขีดแบ่ง LAB หนึ่งรายการขึ้นไป

ปรับค่าขีดแบ่งตามสภาพแสงของคุณ — ปิด auto-gain และ auto-whitebal ก่อน
ส่งค่าขีดแบ่งหลายค่าสำหรับการติดตามหลายสีในการเรียกใช้ครั้งเดียว
pixels_threshold กรองการตรวจจับที่เล็กเกินไป และ merge=True รวมบลอบที่ทับซ้อนกัน
import csi
import time

csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.GRAYSCALE)
csi0.framesize(csi.VGA)
csi0.window((640, 80))  # narrow strip for fast linear scanning
csi0.snapshot(time=2000)  # let AWB/AGC stabilize
csi0.auto_gain(False)
csi0.auto_whitebal(False)

clock = time.clock()

while True:
    clock.tick()
    img = csi0.snapshot()
    for code in img.find_barcodes():
        img.draw_rectangle(code.rect, color=(0, 255, 0))
        print(code.payload, "(quality %d)" % code.quality)
    print(clock.fps(), "fps")

อ่านบาร์โค้ด 1 มิติ

ค้นหาบาร์โค้ด 1 มิติในเฟรมและถอดรหัสเพย์โหลด

ขับเคลื่อนโดยไลบรารี ZBar — รู้จัก EAN, UPC, Code 39/93/128, Codabar, ITF, ISBN, และ DataBar
ใช้แถบหน้าต่างในระดับสีเทาสำหรับการสแกนเชิงเส้นที่เร็วที่สุด
ผลลัพธ์แต่ละรายการมีรูปแบบ, เพย์โหลด, การหมุน, มุม, และกรอบล้อมรอบ
import csi
import time
import ml
from ml.postprocessing.mediapipe import HandLandmarks

csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.RGB565)
csi0.framesize(csi.VGA)
csi0.window((400, 400))  # square window for the model
csi0.snapshot(time=2000)  # let AWB/AGC stabilize

# Connections between the 21 keypoints — palm + 5 fingers.
hand_lines = ((0, 1), (1, 2), (2, 3), (3, 4), (0, 5), (5, 6),
              (6, 7), (7, 8), (5, 9), (9, 10), (10, 11), (11, 12),
              (9, 13), (13, 14), (14, 15), (15, 16), (13, 17), (17, 18),
              (18, 19), (19, 20), (0, 17))

model = ml.Model("/rom/hand_landmarks_full_224.tflite",
                 postprocess=HandLandmarks(threshold=0.4))
clock = time.clock()

while True:
    clock.tick()
    img = csi0.snapshot()
    # predict returns a list per hand: index 0 = left, index 1 = right.
    for detections in model.predict([img]):
        for rect, score, keypoints in detections:
            ml.utils.draw_skeleton(img, keypoints, hand_lines,
                                   kp_color=(255, 0, 0),
                                   line_color=(0, 255, 0))
    print(clock.fps(), "fps")

ติดตาม 21 จุดสำคัญของมือ

โมเดล Hand Landmarks ของ MediaPipe จาก Google ระบุตำแหน่ง 21 ข้อต่อบนมือแต่ละข้าง — ข้อมือ, ข้อนิ้ว, และปลายนิ้ว

โหลดจาก /rom/hand_landmarks_full_224.tflite — รันแบบ standalone ที่นี่ โดยไม่มีการตรวจจับฝ่ามือก่อนหน้า
ส่งคืนรายการหนึ่งรายการต่อมือ — index 0 คือซ้าย, index 1 คือขวา
ml.utils.draw_skeleton วาดข้อต่อและการเชื่อมต่อทั้ง 21 จุดในการเรียกใช้ครั้งเดียว

ใหม่กับ OpenMV?

เริ่มต้นด้วยบทช่วยสอนทีละขั้นตอน — ครอบคลุมการตั้งค่าฮาร์ดแวร์, IDE, สคริปต์พื้นฐาน, และเคล็ดลับสำหรับโปรเจกต์จริงแรกของคุณ

ไลบรารีหลัก

ฮาร์ดแวร์, กล้อง, การประมวลผลภาพ, ndarrays, ML, มัลติทาสก์, เครือข่าย, เว็บเซิร์ฟเวอร์, และ Bluetooth — ทั้งหมดจาก MicroPython

machine

ฮาร์ดแวร์ระดับต่ำ: GPIO, SPI, I²C, UART, PWM, ADC, และตัวจับเวลา

สำรวจ →

csi

การควบคุมกล้อง: รูปแบบพิกเซล, ขนาดเฟรม, การรับแสง, ค่าเกน, และการปรับสมดุลสีขาว

สำรวจ →

image

การมองเห็นของเครื่อง: บลอบ, ขอบ, เส้น, วงกลม, ลักษณะเด่น, และการวาด

สำรวจ →

ulab

การคำนวณตัวเลขบนอุปกรณ์ — ndarrays, FFTs, และพีชคณิตเชิงเส้น

สำรวจ →

ml

การอนุมานโครงข่ายประสาทเทียมบนอุปกรณ์ — จำแนกประเภท, ตรวจจับ, และแบ่งส่วน

สำรวจ →

asyncio

มัลติทาสก์แบบ cooperative — รันกล้อง, เครือข่าย, และ I/O พร้อมกัน

สำรวจ →

network

Wi-Fi, Ethernet, และซ็อกเก็ตสำหรับ IoT และการสื่อสารระยะไกล

สำรวจ →

microdot

เว็บเซิร์ฟเวอร์ขนาดเล็ก — routes, sessions, login, SSE, และ WebSockets

สำรวจ →

aioble

Bluetooth Low Energy แบบ async — peripherals, การโฆษณา, และ GATT

สำรวจ →

ดูไลบรารีทั้งหมด →

สำรวจตามบอร์ด

เลือก OpenMV Cam ของคุณเพื่อดู pinout, สเปก, และเอกสารอ้างอิงด่วนสำหรับบอร์ด

ดูบอร์ดที่รองรับทั้งหมด →

ชิลด์

บอร์ดเสริมที่เสียบกับ OpenMV Cam — เครือข่าย, ควบคุมมอเตอร์, จอแสดงผล และอื่นๆ

ดูชิลด์ทั้งหมด →

เซนเซอร์

โมดูลกล้องและอแดปเตอร์เซนเซอร์ที่เสียบกับขั้วต่อ board-to-board — สี, ขาวดำ, ความร้อน, และวิสัยทัศน์แบบ event-based

ดูเซนเซอร์ทั้งหมด →

แหล่งข้อมูลเพิ่มเติม

ชุมชนและลิงก์