-
Yolo v8 영상인식 기본 사용
준비
pip install opencv-python pip install ultralytics
사용
import cv2 from ultralytics import YOLO model = YOLO('yolov8n.pt') vc1 = None if(not True): # 동영상 파일 사용시 vc1 = cv2.VideoCapture("path/to/your/video/file.mp4") else: # webcam 사용시 vc1 = cv2.VideoCapture(0) while vc1.isOpened(): # Loop through the video frames success, frame = vc1.read() # Read a frame from the video if success: results = model(frame) # Run YOLOv8 inference on the frame annotated_frame = results[0].plot() # Visualize the results on the frame cv2.imshow("YOLOv8 Inference", annotated_frame) # Display the annotated frame # Break the loop if 'q' is pressed if cv2.waitKey(1) & 0xFF == ord("q"): break else: # Break the loop if the end of the video is reached break # Release the video capture object and close the display window vc1.release() cv2.destroyAllWindows()
기타
https://github.com/ultralytics/ultralytics
'영상인식' 카테고리의 다른 글
Yolo v8, ultralytics, PyTorch (0) 2023.08.13 Yolo V8 NodeJs(JavaScript) (0) 2023.07.12 Yolo family series License (0) 2023.07.05 Yolo v8 custom model training Ex (0) 2023.07.05 Python Opencv 영상 입출력 문제 (0) 2021.04.04 Mask R-CNN Demo (0) 2021.04.04 YOLOv2 vs YOLOv3 vs Mask RCNN vs Deeplab Xception (0) 2021.03.05 R-CNN, Fast R-CNN, Faster R-CNN, Mask R-CNN (0) 2021.03.04