blazeface_detector.py

# هذا العمل مرخص بموجب ترخيص MIT.
# حقوق النشر (c) 2013-2025 لشركة OpenMV LLC. جميع الحقوق محفوظة.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# يوضح هذا المثال نموذج MediaPipe من Google لاكتشاف الوجه.

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)

# يتطلب BlazeFace صورة مربعة للحصول على أفضل النتائج.
csi0.window((400, 400))

# تحميل نموذج اكتشاف الوجوه المدمج
model = ml.Model("/rom/blazeface_front_128.tflite", postprocess=BlazeFace(threshold=0.4))
print(model)

clock = time.clock()
while True:
    clock.tick()
    img = csi0.snapshot()

    # faces هي قائمة من مجموعات ((x, y, w, h), score, keypoints)
    for r, score, keypoints in model.predict([img]):
        ml.utils.draw_predictions(img, [r], ("face",), ((0, 0, 255),), format=None)

        # keypoints هي مصفوفة ndarray بشكل (6, 2)
        # 0 - العين اليمنى (x, y)
        # 1 - العين اليسرى (x, y)
        # 2 - الأنف (x, y)
        # 3 - الفم (x, y)
        # 4 - الأذن اليمنى (x, y)
        # 5 - الأذن اليسرى (x, y)
        ml.utils.draw_keypoints(img, keypoints, color=(255, 0, 0))

    print(clock.fps(), "fps")

results matching ""

    No results matching ""