Remove unused arguments in Ultralytics heatmaps (#16667)
Co-authored-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
7325e0bca3
commit
fceaa40038
2 changed files with 2 additions and 21 deletions
|
|
@ -34,11 +34,6 @@ A heatmap generated with [Ultralytics YOLO11](https://github.com/ultralytics/ult
|
||||||
|  |  |
|
|  |  |
|
||||||
| Ultralytics YOLO11 Transportation Heatmap | Ultralytics YOLO11 Retail Heatmap |
|
| Ultralytics YOLO11 Transportation Heatmap | Ultralytics YOLO11 Retail Heatmap |
|
||||||
|
|
||||||
!!! tip "Heatmap Configuration"
|
|
||||||
|
|
||||||
- `heatmap_alpha`: Ensure this value is within the range (0.0 - 1.0).
|
|
||||||
- `decay_factor`: Used for removing heatmap after an object is no longer in the frame, its value should also be in the range (0.0 - 1.0).
|
|
||||||
|
|
||||||
!!! example "Heatmaps using Ultralytics YOLO11 Example"
|
!!! example "Heatmaps using Ultralytics YOLO11 Example"
|
||||||
|
|
||||||
=== "Heatmap"
|
=== "Heatmap"
|
||||||
|
|
@ -274,10 +269,7 @@ A heatmap generated with [Ultralytics YOLO11](https://github.com/ultralytics/ult
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
| ------------------ | ---------------- | ------------------ | ----------------------------------------------------------------- |
|
| ------------------ | ---------------- | ------------------ | ----------------------------------------------------------------- |
|
||||||
| `names` | `list` | `None` | Dictionary of class names. |
|
| `names` | `list` | `None` | Dictionary of class names. |
|
||||||
| `imw` | `int` | `0` | Image width. |
|
|
||||||
| `imh` | `int` | `0` | Image height. |
|
|
||||||
| `colormap` | `int` | `cv2.COLORMAP_JET` | Colormap to use for the heatmap. |
|
| `colormap` | `int` | `cv2.COLORMAP_JET` | Colormap to use for the heatmap. |
|
||||||
| `heatmap_alpha` | `float` | `0.5` | Alpha blending value for heatmap overlay. |
|
|
||||||
| `view_img` | `bool` | `False` | Whether to display the image with the heatmap overlay. |
|
| `view_img` | `bool` | `False` | Whether to display the image with the heatmap overlay. |
|
||||||
| `view_in_counts` | `bool` | `True` | Whether to display the count of objects entering the region. |
|
| `view_in_counts` | `bool` | `True` | Whether to display the count of objects entering the region. |
|
||||||
| `view_out_counts` | `bool` | `True` | Whether to display the count of objects exiting the region. |
|
| `view_out_counts` | `bool` | `True` | Whether to display the count of objects exiting the region. |
|
||||||
|
|
@ -288,7 +280,6 @@ A heatmap generated with [Ultralytics YOLO11](https://github.com/ultralytics/ult
|
||||||
| `region_thickness` | `int` | `5` | Thickness of the region line. |
|
| `region_thickness` | `int` | `5` | Thickness of the region line. |
|
||||||
| `line_dist_thresh` | `int` | `15` | Distance threshold for line-based counting. |
|
| `line_dist_thresh` | `int` | `15` | Distance threshold for line-based counting. |
|
||||||
| `line_thickness` | `int` | `2` | Thickness of the lines used in drawing. |
|
| `line_thickness` | `int` | `2` | Thickness of the lines used in drawing. |
|
||||||
| `decay_factor` | `float` | `0.99` | Decay factor for the heatmap to reduce intensity over time. |
|
|
||||||
| `shape` | `str` | `"circle"` | Shape of the heatmap blobs ('circle' or 'rect'). |
|
| `shape` | `str` | `"circle"` | Shape of the heatmap blobs ('circle' or 'rect'). |
|
||||||
|
|
||||||
### Arguments `model.track`
|
### Arguments `model.track`
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,7 @@ class Heatmap:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
names,
|
names,
|
||||||
imw=0,
|
|
||||||
imh=0,
|
|
||||||
colormap=cv2.COLORMAP_JET,
|
colormap=cv2.COLORMAP_JET,
|
||||||
heatmap_alpha=0.5,
|
|
||||||
view_img=False,
|
view_img=False,
|
||||||
view_in_counts=True,
|
view_in_counts=True,
|
||||||
view_out_counts=True,
|
view_out_counts=True,
|
||||||
|
|
@ -33,7 +30,6 @@ class Heatmap:
|
||||||
region_thickness=5,
|
region_thickness=5,
|
||||||
line_dist_thresh=15,
|
line_dist_thresh=15,
|
||||||
line_thickness=2,
|
line_thickness=2,
|
||||||
decay_factor=0.99,
|
|
||||||
shape="circle",
|
shape="circle",
|
||||||
):
|
):
|
||||||
"""Initializes the heatmap class with default values for Visual, Image, track, count and heatmap parameters."""
|
"""Initializes the heatmap class with default values for Visual, Image, track, count and heatmap parameters."""
|
||||||
|
|
@ -46,8 +42,6 @@ class Heatmap:
|
||||||
self.names = names # Classes names
|
self.names = names # Classes names
|
||||||
|
|
||||||
# Image information
|
# Image information
|
||||||
self.imw = imw
|
|
||||||
self.imh = imh
|
|
||||||
self.im0 = None
|
self.im0 = None
|
||||||
self.tf = line_thickness
|
self.tf = line_thickness
|
||||||
self.view_in_counts = view_in_counts
|
self.view_in_counts = view_in_counts
|
||||||
|
|
@ -56,7 +50,6 @@ class Heatmap:
|
||||||
# Heatmap colormap and heatmap np array
|
# Heatmap colormap and heatmap np array
|
||||||
self.colormap = colormap
|
self.colormap = colormap
|
||||||
self.heatmap = None
|
self.heatmap = None
|
||||||
self.heatmap_alpha = heatmap_alpha
|
|
||||||
|
|
||||||
# Predict/track information
|
# Predict/track information
|
||||||
self.boxes = []
|
self.boxes = []
|
||||||
|
|
@ -79,9 +72,6 @@ class Heatmap:
|
||||||
self.count_bg_color = count_bg_color
|
self.count_bg_color = count_bg_color
|
||||||
self.cls_txtdisplay_gap = 50
|
self.cls_txtdisplay_gap = 50
|
||||||
|
|
||||||
# Decay factor
|
|
||||||
self.decay_factor = decay_factor
|
|
||||||
|
|
||||||
# Check if environment supports imshow
|
# Check if environment supports imshow
|
||||||
self.env_check = check_imshow(warn=True)
|
self.env_check = check_imshow(warn=True)
|
||||||
|
|
||||||
|
|
@ -133,7 +123,7 @@ class Heatmap:
|
||||||
self.heatmap = np.zeros((int(self.im0.shape[0]), int(self.im0.shape[1])), dtype=np.float32)
|
self.heatmap = np.zeros((int(self.im0.shape[0]), int(self.im0.shape[1])), dtype=np.float32)
|
||||||
self.initialized = True
|
self.initialized = True
|
||||||
|
|
||||||
self.heatmap *= self.decay_factor # decay factor
|
self.heatmap *= 0.99 # decay factor
|
||||||
|
|
||||||
self.extract_results(tracks)
|
self.extract_results(tracks)
|
||||||
self.annotator = Annotator(self.im0, self.tf, None)
|
self.annotator = Annotator(self.im0, self.tf, None)
|
||||||
|
|
@ -239,7 +229,7 @@ class Heatmap:
|
||||||
# Normalize, apply colormap to heatmap and combine with original image
|
# Normalize, apply colormap to heatmap and combine with original image
|
||||||
heatmap_normalized = cv2.normalize(self.heatmap, None, 0, 255, cv2.NORM_MINMAX)
|
heatmap_normalized = cv2.normalize(self.heatmap, None, 0, 255, cv2.NORM_MINMAX)
|
||||||
heatmap_colored = cv2.applyColorMap(heatmap_normalized.astype(np.uint8), self.colormap)
|
heatmap_colored = cv2.applyColorMap(heatmap_normalized.astype(np.uint8), self.colormap)
|
||||||
self.im0 = cv2.addWeighted(self.im0, 1 - self.heatmap_alpha, heatmap_colored, self.heatmap_alpha, 0)
|
self.im0 = cv2.addWeighted(self.im0, 0.5, heatmap_colored, 0.5, 0)
|
||||||
|
|
||||||
if self.env_check and self.view_img:
|
if self.env_check and self.view_img:
|
||||||
self.display_frames()
|
self.display_frames()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue