Skip to content

Live Inference using YoloV8 #78

Answered by SkalskiP
PiyushKamboj1503 asked this question in Q&A
Discussion options

You must be logged in to vote
  1. Use get_video_frames_generator
  2. Run detection with YOLOv8 on the current frame
  3. Convert YOLOv8 result to Detections object
  4. Annotate the frame with BoxAnnotator.
  5. Use OpenCV imshow to display annotated images.

Here is a pseudo-code possibly would require some fixing but could be useful as the first iteration.

import cv2
import supervision as sv
from ultralytics import YOLO

model = YOLO('yolov8s.pt')
annotator = BoxAnnotator()

for frame in sv.get_video_frames_generator(source_path='source_video.mp4'):
    yolov8_results = model(frame)[0]
    detections = sv.Detections.from_yolov8(yolov8_results)
    annotated_frame = annotator.annotate(scene=frame.copy(), detections=detections)
    cv2.imshow

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by PiyushKamboj1503
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants
Converted from issue

This discussion was converted from issue #77 on April 27, 2023 11:09.