Sobes.tech
Middle — Senior

¿Qué es un bounding box y qué formatos de coordenadas existen (xyxy, xywh, cxcywh)?

sobes.tech AI

Respuesta de la IA

Bounding box — es un rectángulo que limita un objeto en una imagen, utilizado en tareas de visión por computadora para localizar objetos.

Formatos de coordenadas:

  • xyxy — coordenadas de dos esquinas: (x_min, y_min, x_max, y_max). Por ejemplo, las esquinas superior izquierda e inferior derecha.
  • xywh — coordenadas de la esquina superior izquierda y dimensiones: (x_min, y_min, ancho, alto).
  • cxcywh — coordenadas del centro y dimensiones: (centro_x, centro_y, ancho, alto).

Ejemplo:

# Formato xyxy
bbox_xyxy = [50, 30, 200, 180]  # x_min=50, y_min=30, x_max=200, y_max=180

# Conversión a xywh
x_min, y_min, x_max, y_max = bbox_xyxy
width = x_max - x_min
height = y_max - y_min
bbox_xywh = [x_min, y_min, width, height]

# Conversión a cxcywh
center_x = x_min + width / 2
center_y = y_min + height / 2
bbox_cxcywh = [center_x, center_y, width, height]

La elección del formato depende de la tarea y los algoritmos utilizados.