Relative Content

Tag Archive for image-processingcoordinatesyolobounding-boxyolov8

How to extract bounding boxes from the object detected in an image for yolov8

from ultralytics import YOLO import cv2 def detect_and_visualize_objects_yolov8(image_path, model, confidence_threshold=0.5): image = cv2.imread(image_path) results = model(image) boxes = [] confidences = [] for result in results: for box in result.boxes: if box.conf > confidence_threshold: # Extract bounding box coordinates –> x1, y1, x2, y2 = box.xyxy[0].item(), box.xyxy[1].item(), box.xyxy[2].item(), box.xyxy[3].item() x1, y1, x2, y2 = int(x1), […]