yolo_lc_person_detector.py

# هذا العمل مرخص بموجب ترخيص MIT.
# حقوق النشر (c) 2013-2025 لشركة OpenMV LLC. جميع الحقوق محفوظة.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# مثال كاشف الأشخاص TensorFlow Lite YOLO LC
#
# YOLO LC هو نسخة مشتقة من YOLOV2 سريعة بما يكفي للعمل على كاميرات OpenMV التي لا تحتوي على وحدات NPU.

import csi
import time
import ml
from ml.postprocessing.darknet import YoloLC

# تهيئة المستشعر.
csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.RGB565)
csi0.framesize(csi.VGA)

# تحميل نموذج اكتشاف الأشخاص المدمج
model = ml.Model("/rom/yolo_lc_192.tflite", postprocess=YoloLC(threshold=0.4))
print(model)

# معاملات التصور المرئي.
n = len(model.labels)
model_class_colors = [(int(255 * i // n), int(255 * (n - i - 1) // n), 255) for i in range(n)]

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

    # boxes عبارة عن قائمة من القوائم لكل فئة تحتوي على صفوف (tuples) بالشكل ((x, y, w, h), score)
    boxes = model.predict([img])

    # رسم مربعات إحاطة حول الأجسام المكتشفة
    for i, class_detections in enumerate(boxes):
        rects = [r for r, score in class_detections]
        labels = [model.labels[i] for j in range(len(rects))]
        colors = [model_class_colors[i] for j in range(len(rects))]
        ml.utils.draw_predictions(img, rects, labels, colors, format=None)

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

results matching ""

    No results matching ""