رسم خرائط كائن عرض VisionEye باستخدام Ultralytics YOLOv8 🚀
ما هو رسم خرائط كائن VisionEye؟
Ultralytics YOLOv8 يوفر VisionEye القدرة لأجهزة الكمبيوتر على تحديد الأشياء وتحديدها ، ومحاكاة دقة المراقبة للعين البشرية. تمكن هذه الوظيفة أجهزة الكمبيوتر من تمييز أشياء محددة والتركيز عليها ، تماما مثل الطريقة التي تراقب بها العين البشرية التفاصيل من وجهة نظر معينة.
العينات
فيجن آي فيو | عرض VisionEye مع تتبع الكائن | عرض VisionEye مع حساب المسافة |
---|---|---|
رسم خرائط كائن عرض VisionEye باستخدام Ultralytics YOLOv8 | رسم خرائط كائن VisionEye View مع تتبع الكائن باستخدام Ultralytics YOLOv8 | عرض VisionEye مع حساب المسافة باستخدام Ultralytics YOLOv8 |
رسم خرائط كائن VisionEye باستخدام YOLOv8
import cv2
from ultralytics import YOLO
from ultralytics.utils.plotting import Annotator, colors
model = YOLO("yolov8n.pt")
names = model.model.names
cap = cv2.VideoCapture("path/to/video/file.mp4")
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))
out = cv2.VideoWriter("visioneye-pinpoint.avi", cv2.VideoWriter_fourcc(*"MJPG"), fps, (w, h))
center_point = (-10, h)
while True:
ret, im0 = cap.read()
if not ret:
print("Video frame is empty or video processing has been successfully completed.")
break
results = model.predict(im0)
boxes = results[0].boxes.xyxy.cpu()
clss = results[0].boxes.cls.cpu().tolist()
annotator = Annotator(im0, line_width=2)
for box, cls in zip(boxes, clss):
annotator.box_label(box, label=names[int(cls)], color=colors(int(cls)))
annotator.visioneye(box, center_point)
out.write(im0)
cv2.imshow("visioneye-pinpoint", im0)
if cv2.waitKey(1) & 0xFF == ord("q"):
break
out.release()
cap.release()
cv2.destroyAllWindows()
import cv2
from ultralytics import YOLO
from ultralytics.utils.plotting import Annotator, colors
model = YOLO("yolov8n.pt")
cap = cv2.VideoCapture("path/to/video/file.mp4")
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))
out = cv2.VideoWriter("visioneye-pinpoint.avi", cv2.VideoWriter_fourcc(*"MJPG"), fps, (w, h))
center_point = (-10, h)
while True:
ret, im0 = cap.read()
if not ret:
print("Video frame is empty or video processing has been successfully completed.")
break
annotator = Annotator(im0, line_width=2)
results = model.track(im0, persist=True)
boxes = results[0].boxes.xyxy.cpu()
if results[0].boxes.id is not None:
track_ids = results[0].boxes.id.int().cpu().tolist()
for box, track_id in zip(boxes, track_ids):
annotator.box_label(box, label=str(track_id), color=colors(int(track_id)))
annotator.visioneye(box, center_point)
out.write(im0)
cv2.imshow("visioneye-pinpoint", im0)
if cv2.waitKey(1) & 0xFF == ord("q"):
break
out.release()
cap.release()
cv2.destroyAllWindows()
import math
import cv2
from ultralytics import YOLO
from ultralytics.utils.plotting import Annotator
model = YOLO("yolov8s.pt")
cap = cv2.VideoCapture("Path/to/video/file.mp4")
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))
out = cv2.VideoWriter("visioneye-distance-calculation.avi", cv2.VideoWriter_fourcc(*"MJPG"), fps, (w, h))
center_point = (0, h)
pixel_per_meter = 10
txt_color, txt_background, bbox_clr = ((0, 0, 0), (255, 255, 255), (255, 0, 255))
while True:
ret, im0 = cap.read()
if not ret:
print("Video frame is empty or video processing has been successfully completed.")
break
annotator = Annotator(im0, line_width=2)
results = model.track(im0, persist=True)
boxes = results[0].boxes.xyxy.cpu()
if results[0].boxes.id is not None:
track_ids = results[0].boxes.id.int().cpu().tolist()
for box, track_id in zip(boxes, track_ids):
annotator.box_label(box, label=str(track_id), color=bbox_clr)
annotator.visioneye(box, center_point)
x1, y1 = int((box[0] + box[2]) // 2), int((box[1] + box[3]) // 2) # Bounding box centroid
distance = (math.sqrt((x1 - center_point[0]) ** 2 + (y1 - center_point[1]) ** 2)) / pixel_per_meter
text_size, _ = cv2.getTextSize(f"Distance: {distance:.2f} m", cv2.FONT_HERSHEY_SIMPLEX, 1.2, 3)
cv2.rectangle(im0, (x1, y1 - text_size[1] - 10), (x1 + text_size[0] + 10, y1), txt_background, -1)
cv2.putText(im0, f"Distance: {distance:.2f} m", (x1, y1 - 5), cv2.FONT_HERSHEY_SIMPLEX, 1.2, txt_color, 3)
out.write(im0)
cv2.imshow("visioneye-distance-calculation", im0)
if cv2.waitKey(1) & 0xFF == ord("q"):
break
out.release()
cap.release()
cv2.destroyAllWindows()
visioneye
الحجج
اسم | نوع | افتراضي | وصف |
---|---|---|---|
color |
tuple |
(235, 219, 11) |
لون الخط والكائن المركزي |
pin_color |
tuple |
(255, 0, 255) |
فيجن آي لون محدد |
ملاحظه
لأية استفسارات ، لا تتردد في نشر أسئلتك في Ultralytics قسم المشكلة أو قسم المناقشة المذكور أدناه.
الأسئلة المتداولة
كيف يمكنني البدء في استخدام VisionEye Object Mapping مع Ultralytics YOLOv8 ؟
للبدء في استخدام VisionEye Object Mapping مع Ultralytics YOLOv8 ، ستحتاج أولاً إلى تثبيت الحزمة Ultralytics YOLO عبر pip. بعد ذلك، يمكنك استخدام نموذج التعليمات البرمجية المتوفرة في الوثائق لإعداد اكتشاف الكائنات باستخدام VisionEye. إليك مثال بسيط لتبدأ:
import cv2
from ultralytics import YOLO
model = YOLO("yolov8n.pt")
cap = cv2.VideoCapture("path/to/video/file.mp4")
while True:
ret, frame = cap.read()
if not ret:
break
results = model.predict(frame)
for result in results:
# Perform custom logic with result
pass
cv2.imshow("visioneye", frame)
if cv2.waitKey(1) & 0xFF == ord("q"):
break
cap.release()
cv2.destroyAllWindows()
ما هي الميزات الرئيسية لقدرة VisionEye على تتبع الأجسام باستخدام Ultralytics YOLOv8 ؟
تتيح خاصية تتبع الأجسام من VisionEye مع Ultralytics YOLOv8 للمستخدمين متابعة حركة الأجسام داخل إطار الفيديو. تشمل الميزات الرئيسية ما يلي:
- تتبع الأجسام في الوقت الحقيقي: يواكب الأجسام أثناء تحركها.
- تحديد الكائنات: يستخدم خوارزميات الكشف القوية YOLOv8.
- حساب المسافات: حساب المسافات بين الأجسام والنقاط المحددة.
- التعليق التوضيحي والتصور: يوفر علامات مرئية للأجسام المتعقبة.
إليك مقتطف رمز موجز يوضح التتبع باستخدام VisionEye:
import cv2
from ultralytics import YOLO
model = YOLO("yolov8n.pt")
cap = cv2.VideoCapture("path/to/video/file.mp4")
while True:
ret, frame = cap.read()
if not ret:
break
results = model.track(frame, persist=True)
for result in results:
# Annotate and visualize tracking
pass
cv2.imshow("visioneye-tracking", frame)
if cv2.waitKey(1) & 0xFF == ord("q"):
break
cap.release()
cv2.destroyAllWindows()
للاطلاع على دليل شامل، قم بزيارة دليل VisionEye لتخطيط الكائنات مع تتبع الكائنات.
كيف يمكنني حساب المسافات باستخدام نموذج VisionEye YOLOv8 ؟
يتضمن حساب المسافة باستخدام VisionEye و Ultralytics YOLOv8 تحديد مسافة الأجسام المكتشفة من نقطة محددة في الإطار. يعزز قدرات التحليل المكاني، وهو مفيد في تطبيقات مثل القيادة الذاتية والمراقبة.
إليك مثالاً مبسطاً:
import math
import cv2
from ultralytics import YOLO
model = YOLO("yolov8s.pt")
cap = cv2.VideoCapture("path/to/video/file.mp4")
center_point = (0, 480) # Example center point
pixel_per_meter = 10
while True:
ret, frame = cap.read()
if not ret:
break
results = model.track(frame, persist=True)
for result in results:
# Calculate distance logic
distances = [
(math.sqrt((box[0] - center_point[0]) ** 2 + (box[1] - center_point[1]) ** 2)) / pixel_per_meter
for box in results
]
cv2.imshow("visioneye-distance", frame)
if cv2.waitKey(1) & 0xFF == ord("q"):
break
cap.release()
cv2.destroyAllWindows()
للحصول على تعليمات مفصلة، ارجع إلى VisionEye مع حساب المسافة.
لماذا يجب استخدام Ultralytics YOLOv8 لتعيين الكائنات وتتبعها؟
Ultralytics YOLOv8 يشتهر بالسرعة والدقة وسهولة التكامل، مما يجعله الخيار الأفضل لتعيين الأجسام وتتبعها. تشمل المزايا الرئيسية ما يلي:
- أداء متطور للغاية: يوفر دقة عالية في اكتشاف الأجسام في الوقت الحقيقي.
- المرونة: يدعم مهام مختلفة مثل الكشف والتتبع وحساب المسافة.
- المجتمع والدعم: وثائق موسعة ومجتمع GitHub نشط لاستكشاف الأخطاء وإصلاحها والتحسينات.
- سهولة الاستخدام: تعمل واجهة برمجة التطبيقات البديهية على تبسيط المهام المعقدة، مما يسمح بالنشر والتكرار السريع.
للمزيد من المعلومات حول التطبيقات والمزايا، اطلع على وثائقUltralytics YOLOv8 .
كيف يمكنني دمج VisionEye مع أدوات التعلم الآلي الأخرى مثل Comet أو ClearML ؟
Ultralytics YOLOv8 يمكن أن تتكامل بسلاسة مع العديد من أدوات التعلم الآلي مثل Comet و ClearML ، مما يعزز تتبع التجارب والتعاون وقابلية التكرار. اتبع الأدلة التفصيلية حول كيفية استخدام YOLOv5 مع Comet ودمج YOLOv8 مع ClearML للبدء.
لمزيد من الاستكشاف وأمثلة التكامل، راجع دليل التكاملUltralytics .
تم الإنشاء 2023-12-18، تم التحديث 2024-07-05
المؤلفون: جلين-جوتشر (13)، إيفور زو331 (1)، رضوان منور (1)