Advanced Data Visualization: Heatmaps using Ultralytics YOLO11 🚀
Introducción a los mapas de calor
A heatmap generated with Ultralytics YOLO11 transforms complex data into a vibrant, color-coded matrix. This visual tool employs a spectrum of colors to represent varying data values, where warmer hues indicate higher intensities and cooler tones signify lower values. Heatmaps excel in visualizing intricate data patterns, correlations, and anomalies, offering an accessible and engaging approach to data interpretation across diverse domains.
Observa: Heatmaps using Ultralytics YOLO11
¿Por qué elegir mapas de calor para el análisis de datos?
- Visualización intuitiva de la distribución de los datos: Los mapas de calor simplifican la comprensión de la concentración y distribución de los datos, convirtiendo conjuntos de datos complejos en formatos visuales fáciles de entender.
- Detección eficaz de patrones: Al visualizar los datos en formato de mapa de calor, resulta más fácil detectar tendencias, agrupaciones y valores atípicos, lo que facilita un análisis y una comprensión más rápidos.
- Mejora del análisis espacial y la toma de decisiones: Los mapas de calor son fundamentales para ilustrar las relaciones espaciales, ayudando en los procesos de toma de decisiones en sectores como la inteligencia empresarial, los estudios medioambientales y la planificación urbana.
Aplicaciones en el mundo real
Transporte | Venta al por menor |
---|---|
Ultralytics YOLO11 Transportation Heatmap | Ultralytics YOLO11 Retail Heatmap |
Heatmaps using Ultralytics YOLO11 Example
import cv2
from ultralytics import solutions
cap = cv2.VideoCapture("Path/to/video/file.mp4")
assert cap.isOpened(), "Error reading video file"
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))
# Video writer
video_writer = cv2.VideoWriter("heatmap_output.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))
# Init heatmap
heatmap = solutions.Heatmap(
show=True,
model="yolo11n.pt",
colormap=cv2.COLORMAP_PARULA,
)
while cap.isOpened():
success, im0 = cap.read()
if not success:
print("Video frame is empty or video processing has been successfully completed.")
break
im0 = heatmap.generate_heatmap(im0)
video_writer.write(im0)
cap.release()
video_writer.release()
cv2.destroyAllWindows()
import cv2
from ultralytics import solutions
cap = cv2.VideoCapture("Path/to/video/file.mp4")
assert cap.isOpened(), "Error reading video file"
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))
# Video writer
video_writer = cv2.VideoWriter("heatmap_output.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))
# line for object counting
line_points = [(20, 400), (1080, 404)]
# Init heatmap
heatmap = solutions.Heatmap(
show=True,
model="yolo11n.pt",
colormap=cv2.COLORMAP_PARULA,
region=line_points,
)
while cap.isOpened():
success, im0 = cap.read()
if not success:
print("Video frame is empty or video processing has been successfully completed.")
break
im0 = heatmap.generate_heatmap(im0)
video_writer.write(im0)
cap.release()
video_writer.release()
cv2.destroyAllWindows()
import cv2
from ultralytics import solutions
cap = cv2.VideoCapture("Path/to/video/file.mp4")
assert cap.isOpened(), "Error reading video file"
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))
# Video writer
video_writer = cv2.VideoWriter("heatmap_output.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))
# Define polygon points
region_points = [(20, 400), (1080, 404), (1080, 360), (20, 360), (20, 400)]
# Init heatmap
heatmap = solutions.Heatmap(
show=True,
model="yolo11n.pt",
colormap=cv2.COLORMAP_PARULA,
region=region_points,
)
while cap.isOpened():
success, im0 = cap.read()
if not success:
print("Video frame is empty or video processing has been successfully completed.")
break
im0 = heatmap.generate_heatmap(im0)
video_writer.write(im0)
cap.release()
video_writer.release()
cv2.destroyAllWindows()
import cv2
from ultralytics import solutions
cap = cv2.VideoCapture("Path/to/video/file.mp4")
assert cap.isOpened(), "Error reading video file"
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))
# Video writer
video_writer = cv2.VideoWriter("heatmap_output.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))
# Define region points
region_points = [(20, 400), (1080, 404), (1080, 360), (20, 360)]
# Init heatmap
heatmap = solutions.Heatmap(
show=True,
model="yolo11n.pt",
colormap=cv2.COLORMAP_PARULA,
region=region_points,
)
while cap.isOpened():
success, im0 = cap.read()
if not success:
print("Video frame is empty or video processing has been successfully completed.")
break
im0 = heatmap.generate_heatmap(im0)
video_writer.write(im0)
cap.release()
video_writer.release()
cv2.destroyAllWindows()
import cv2
from ultralytics import solutions
cap = cv2.VideoCapture("Path/to/video/file.mp4")
assert cap.isOpened(), "Error reading video file"
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))
# Video writer
video_writer = cv2.VideoWriter("heatmap_output.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))
# Init heatmap
heatmap = solutions.Heatmap(
show=True,
model="yolo11n.pt",
classes=[0, 2],
)
while cap.isOpened():
success, im0 = cap.read()
if not success:
print("Video frame is empty or video processing has been successfully completed.")
break
im0 = heatmap.generate_heatmap(im0)
video_writer.write(im0)
cap.release()
video_writer.release()
cv2.destroyAllWindows()
Argumentos Heatmap()
Nombre | Tipo | Por defecto | Descripción |
---|---|---|---|
colormap |
int |
cv2.COLORMAP_JET |
Mapa de color a utilizar para el mapa de calor. |
show |
bool |
False |
Si mostrar la imagen con la superposición del mapa de calor. |
show_in |
bool |
True |
Si se muestra el recuento de objetos que entran en la región. |
show_out |
bool |
True |
Si se muestra el recuento de objetos que salen de la región. |
region |
list |
None |
Puntos que definen la región de recuento (una línea o un polígono). |
line_width |
int |
2 |
Grosor de las líneas utilizadas en el dibujo. |
Argumentos model.track
Argumento | Tipo | Por defecto | Descripción |
---|---|---|---|
source |
str |
None |
Specifies the source directory for images or videos. Supports file paths and URLs. |
persist |
bool |
False |
Enables persistent tracking of objects between frames, maintaining IDs across video sequences. |
tracker |
str |
botsort.yaml |
Specifies the tracking algorithm to use, e.g., bytetrack.yaml o botsort.yaml . |
conf |
float |
0.3 |
Sets the confidence threshold for detections; lower values allow more objects to be tracked but may include false positives. |
iou |
float |
0.5 |
Sets the Intersection over Union (IoU) threshold for filtering overlapping detections. |
classes |
list |
None |
Filters results by class index. For example, classes=[0, 2, 3] only tracks the specified classes. |
verbose |
bool |
True |
Controls the display of tracking results, providing a visual output of tracked objects. |
Mapa térmico COLORMAPAS
Nombre del mapa de colores | Descripción |
---|---|
cv::COLORMAP_AUTUMN |
Mapa de colores de otoño |
cv::COLORMAP_BONE |
Mapa de color de los huesos |
cv::COLORMAP_JET |
Mapa de color del chorro |
cv::COLORMAP_WINTER |
Mapa de colores de invierno |
cv::COLORMAP_RAINBOW |
Mapa de colores del arco iris |
cv::COLORMAP_OCEAN |
Mapa del color del océano |
cv::COLORMAP_SUMMER |
Mapa de colores de verano |
cv::COLORMAP_SPRING |
Mapa de colores de primavera |
cv::COLORMAP_COOL |
Bonito mapa de colores |
cv::COLORMAP_HSV |
Mapa de color HSV (Tono, Saturación, Valor) |
cv::COLORMAP_PINK |
Mapa de color rosa |
cv::COLORMAP_HOT |
Mapa de colores calientes |
cv::COLORMAP_PARULA |
Mapa de colores de Parula |
cv::COLORMAP_MAGMA |
Mapa de colores del magma |
cv::COLORMAP_INFERNO |
Mapa de colores de Inferno |
cv::COLORMAP_PLASMA |
Mapa de colores del plasma |
cv::COLORMAP_VIRIDIS |
Mapa de colores de Viridis |
cv::COLORMAP_CIVIDIS |
Mapa en color de Cividis |
cv::COLORMAP_TWILIGHT |
Mapa de colores del crepúsculo |
cv::COLORMAP_TWILIGHT_SHIFTED |
Mapa de colores del Crepúsculo desplazado |
cv::COLORMAP_TURBO |
Mapa de colores turbo |
cv::COLORMAP_DEEPGREEN |
Mapa de color Verde Profundo |
Estos mapas de colores se utilizan habitualmente para visualizar datos con diferentes representaciones de color.
PREGUNTAS FRECUENTES
How does Ultralytics YOLO11 generate heatmaps and what are their benefits?
Ultralytics YOLO11 generates heatmaps by transforming complex data into a color-coded matrix where different hues represent data intensities. Heatmaps make it easier to visualize patterns, correlations, and anomalies in the data. Warmer hues indicate higher values, while cooler tones represent lower values. The primary benefits include intuitive visualization of data distribution, efficient pattern detection, and enhanced spatial analysis for decision-making. For more details and configuration options, refer to the Heatmap Configuration section.
Can I use Ultralytics YOLO11 to perform object tracking and generate a heatmap simultaneously?
Yes, Ultralytics YOLO11 supports object tracking and heatmap generation concurrently. This can be achieved through its Heatmap
solution integrated with object tracking models. To do so, you need to initialize the heatmap object and use YOLO11's tracking capabilities. Here's a simple example:
import cv2
from ultralytics import solutions
cap = cv2.VideoCapture("path/to/video/file.mp4")
heatmap = solutions.Heatmap(colormap=cv2.COLORMAP_PARULA, show=True, model="yolo11n.pt")
while cap.isOpened():
success, im0 = cap.read()
if not success:
break
im0 = heatmap.generate_heatmap(im0)
cv2.imshow("Heatmap", im0)
if cv2.waitKey(1) & 0xFF == ord("q"):
break
cap.release()
cv2.destroyAllWindows()
Para más orientación, consulta la página Modo de seguimiento.
What makes Ultralytics YOLO11 heatmaps different from other data visualization tools like those from OpenCV or Matplotlib?
Ultralytics YOLO11 heatmaps are specifically designed for integration with its object detection and tracking models, providing an end-to-end solution for real-time data analysis. Unlike generic visualization tools like OpenCV or Matplotlib, YOLO11 heatmaps are optimized for performance and automated processing, supporting features like persistent tracking, decay factor adjustment, and real-time video overlay. For more information on YOLO11's unique features, visit the Ultralytics YOLO11 Introduction.
How can I visualize only specific object classes in heatmaps using Ultralytics YOLO11?
Puedes visualizar clases específicas de objetos especificando las clases deseadas en el campo track()
del modelo YOLO . Por ejemplo, si sólo quieres visualizar coches y personas (suponiendo que sus índices de clase sean 0 y 2), puedes establecer el método classes
en consecuencia.
import cv2
from ultralytics import solutions
cap = cv2.VideoCapture("path/to/video/file.mp4")
heatmap = solutions.Heatmap(show=True, model="yolo11n.pt", classes=[0, 2])
while cap.isOpened():
success, im0 = cap.read()
if not success:
break
im0 = heatmap.generate_heatmap(im0)
cv2.imshow("Heatmap", im0)
if cv2.waitKey(1) & 0xFF == ord("q"):
break
cap.release()
cv2.destroyAllWindows()
Why should businesses choose Ultralytics YOLO11 for heatmap generation in data analysis?
Ultralytics YOLO11 offers seamless integration of advanced object detection and real-time heatmap generation, making it an ideal choice for businesses looking to visualize data more effectively. The key advantages include intuitive data distribution visualization, efficient pattern detection, and enhanced spatial analysis for better decision-making. Additionally, YOLO11's cutting-edge features such as persistent tracking, customizable colormaps, and support for various export formats make it superior to other tools like TensorFlow and OpenCV for comprehensive data analysis. Learn more about business applications at Ultralytics Plans.