Skip to content

Advanced Data Visualization: Heatmaps using Ultralytics YOLO11 🚀

Introduction aux cartes thermiques

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.



Regarde : Heatmaps using Ultralytics YOLO11

Pourquoi choisir les cartes thermiques pour l'analyse des données ?

  • Visualisation intuitive de la distribution des donnĂ©es : Les cartes thermiques simplifient la comprĂ©hension de la concentration et de la distribution des donnĂ©es, en convertissant des ensembles de donnĂ©es complexes en formats visuels faciles Ă  comprendre.
  • DĂ©tection efficace des tendances : En visualisant les donnĂ©es sous forme de carte thermique, il devient plus facile de repĂ©rer les tendances, les grappes et les valeurs aberrantes, ce qui facilite une analyse et des idĂ©es plus rapides.
  • AmĂ©lioration de l'analyse spatiale et de la prise de dĂ©cision : les cartes thermiques permettent d'illustrer les relations spatiales et de faciliter les processus de prise de dĂ©cision dans des secteurs tels que l'intelligence Ă©conomique, les Ă©tudes environnementales et l'urbanisme.

Applications dans le monde réel

Transport Vente au détail
Ultralytics YOLO11 Transportation Heatmap Ultralytics YOLO11 Retail Heatmap
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()

Arguments Heatmap()

Nom Type DĂ©faut Description
colormap int cv2.COLORMAP_JET Carte de couleurs Ă  utiliser pour la carte thermique.
show bool False Permet d'afficher ou non l'image avec la superposition de la carte thermique.
show_in bool True Affiche ou non le nombre d'objets entrant dans la région.
show_out bool True Affiche ou non le nombre d'objets qui sortent de la région.
region list None Points définissant la région de comptage (soit une ligne, soit un polygone).
line_width int 2 Épaisseur des lignes utilisées pour le dessin.

Arguments model.track

Argument Type DĂ©faut Description
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 ou 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.

Carte thermique COLORMAPs

Nom de la carte de couleurs Description
cv::COLORMAP_AUTUMN Carte des couleurs d'automne
cv::COLORMAP_BONE Carte des couleurs des os
cv::COLORMAP_JET Carte des couleurs du jet
cv::COLORMAP_WINTER Carte des couleurs de l'hiver
cv::COLORMAP_RAINBOW Carte des couleurs de l'arc-en-ciel
cv::COLORMAP_OCEAN Carte des couleurs de l'océan
cv::COLORMAP_SUMMER Carte des couleurs de l'été
cv::COLORMAP_SPRING Carte des couleurs du printemps
cv::COLORMAP_COOL Superbe carte des couleurs
cv::COLORMAP_HSV Carte de couleurs HSV (teinte, saturation, valeur)
cv::COLORMAP_PINK Carte en couleur rose
cv::COLORMAP_HOT Carte des couleurs chaudes
cv::COLORMAP_PARULA Carte des couleurs de Parula
cv::COLORMAP_MAGMA Carte des couleurs du magma
cv::COLORMAP_INFERNO Carte des couleurs d'Inferno
cv::COLORMAP_PLASMA Carte des couleurs du plasma
cv::COLORMAP_VIRIDIS Carte des couleurs de Viridis
cv::COLORMAP_CIVIDIS Carte des couleurs de Cividis
cv::COLORMAP_TWILIGHT Carte couleur du crépuscule
cv::COLORMAP_TWILIGHT_SHIFTED Carte des couleurs du crépuscule décalé
cv::COLORMAP_TURBO Carte des couleurs du turbo
cv::COLORMAP_DEEPGREEN Carte des couleurs du vert profond

Ces cartes de couleurs sont couramment utilisées pour visualiser les données avec des représentations de couleurs différentes.

FAQ

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()

Pour plus de conseils, consulte la page sur le mode de suivi.

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?

Tu peux visualiser des classes d'objets spécifiques en spécifiant les classes souhaitées dans la rubrique track() du modèle YOLO . Par exemple, si tu ne veux visualiser que les voitures et les personnes (en supposant que leurs indices de classe sont 0 et 2), tu peux définir le paramètre classes en conséquence.

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.


📅 Created 10 months ago ✏️ Updated 7 days ago

Commentaires