Advanced Data Visualization: Heatmaps using Ultralytics YOLO11 🚀
ヒートマップ入門
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.
見るんだ: Heatmaps using Ultralytics YOLO11
データ分析にヒートマップを選ぶ理由
- 直感的なデータ分布の視覚化:ヒートマップは、データの集中と分布の理解を単純化し、複雑なデータセットを理解しやすいビジュアル形式に変換します。
- 効率的なパターン検出:データをヒートマップ形式で可視化することで、トレンド、クラスター、異常値を見つけやすくなり、迅速な分析と洞察が容易になります。
- 空間分析と意思決定の強化:ヒートマップは空間的な関係を図示するのに役立ち、ビジネスインテリジェンス、環境調査、都市計画などの分野における意思決定プロセスを支援する。
実世界での応用
交通 | 小売 |
---|---|
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()
論争 Heatmap()
名称 | タイプ | デフォルト | 説明 |
---|---|---|---|
model |
str |
None |
Path to Ultralytics YOLO Model File |
colormap |
int |
cv2.COLORMAP_JET |
ヒートマップに使用するカラーマップ。 |
show |
bool |
False |
画像をヒートマップオーバーレイで表示するかどうか。 |
show_in |
bool |
True |
リージョンに入るオブジェクトの数を表示するかどうか。 |
show_out |
bool |
True |
リージョンから出ていくオブジェクトの数を表示するかどうか。 |
region |
list |
None |
計数領域を定義する点(線または多角形)。 |
line_width |
int |
2 |
描画に使用する線の太さ。 |
論争 model.track
議論 | タイプ | デフォルト | 説明 |
---|---|---|---|
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 または 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. |
ヒートマップ COLORMAPs
カラーマップ名 | 説明 |
---|---|
cv::COLORMAP_AUTUMN |
紅葉マップ |
cv::COLORMAP_BONE |
骨カラーマップ |
cv::COLORMAP_JET |
ジェットカラー・マップ |
cv::COLORMAP_WINTER |
冬のカラーマップ |
cv::COLORMAP_RAINBOW |
虹色マップ |
cv::COLORMAP_OCEAN |
海の色マップ |
cv::COLORMAP_SUMMER |
夏色マップ |
cv::COLORMAP_SPRING |
春のカラーマップ |
cv::COLORMAP_COOL |
クールなカラーマップ |
cv::COLORMAP_HSV |
HSV(色相・彩度・明度)カラーマップ |
cv::COLORMAP_PINK |
ピンクのカラーマップ |
cv::COLORMAP_HOT |
ホットカラーマップ |
cv::COLORMAP_PARULA |
パルーラ カラーマップ |
cv::COLORMAP_MAGMA |
マグマ・カラーマップ |
cv::COLORMAP_INFERNO |
インフェルノ カラーマップ |
cv::COLORMAP_PLASMA |
プラズマカラーマップ |
cv::COLORMAP_VIRIDIS |
ヴィリディス カラーマップ |
cv::COLORMAP_CIVIDIS |
チヴィディス カラーマップ |
cv::COLORMAP_TWILIGHT |
トワイライト・カラー・マップ |
cv::COLORMAP_TWILIGHT_SHIFTED |
シフトトワイライトカラーマップ |
cv::COLORMAP_TURBO |
ターボカラーマップ |
cv::COLORMAP_DEEPGREEN |
ディープグリーンのカラーマップ |
このようなカラーマップは、異なる色表現でデータを視覚化するためによく使われる。
よくあるご質問
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()
詳しいガイダンスについては、トラッキングモードのページをご覧ください。
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?
で必要なクラスを指定することで、特定のオブジェクト・クラスを視覚化できます。 track()
YOLO メソッドを呼び出します。例えば、車と人(クラスインデックスが0と2であると仮定)のみを可視化したい場合は classes
パラメータを使用する。
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.