Refactor all Ultralytics Solutions (#12790)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
Co-authored-by: RizwanMunawar <chr043416@gmail.com>
This commit is contained in:
Glenn Jocher 2024-05-18 18:14:42 +02:00 committed by GitHub
parent a2ecb24176
commit 2af71d15a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
134 changed files with 845 additions and 1020 deletions

View file

@ -39,8 +39,7 @@ Speed estimation is the process of calculating the rate of movement of an object
=== "Speed Estimation"
```python
from ultralytics import YOLO
from ultralytics.solutions import speed_estimation
from ultralytics import YOLO, solutions
import cv2
model = YOLO("yolov8n.pt")
@ -51,18 +50,14 @@ Speed estimation is the process of calculating the rate of movement of an object
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("speed_estimation.avi",
cv2.VideoWriter_fourcc(*'mp4v'),
fps,
(w, h))
video_writer = cv2.VideoWriter("speed_estimation.avi", cv2.VideoWriter_fourcc(*'mp4v'), fps, (w, h))
line_pts = [(0, 360), (1280, 360)]
# Init speed-estimation obj
speed_obj = speed_estimation.SpeedEstimator()
speed_obj.set_args(reg_pts=line_pts,
names=names,
view_img=True)
speed_obj = solutions.SpeedEstimator(reg_pts=line_pts,
names=names,
view_img=True)
while cap.isOpened():
@ -86,16 +81,16 @@ Speed estimation is the process of calculating the rate of movement of an object
Speed will be an estimate and may not be completely accurate. Additionally, the estimation can vary depending on GPU speed.
### Optional Arguments `set_args`
### Arguments `SpeedEstimator`
| Name | Type | Default | Description |
|--------------------|--------|----------------------------|---------------------------------------------------|
| `reg_pts` | `list` | `[(20, 400), (1260, 400)]` | Points defining the Region Area |
| `names` | `dict` | `None` | Classes names |
| `view_img` | `bool` | `False` | Display frames with counts |
| `line_thickness` | `int` | `2` | Increase bounding boxes thickness |
| `region_thickness` | `int` | `5` | Thickness for object counter region or line |
| `spdl_dist_thresh` | `int` | `10` | Euclidean Distance threshold for speed check line |
| Name | Type | Default | Description |
|--------------------|--------|----------------------------|------------------------------------------------------|
| `names` | `dict` | `None` | Dictionary of class names. |
| `reg_pts` | `list` | `[(20, 400), (1260, 400)]` | List of region points for speed estimation. |
| `view_img` | `bool` | `False` | Whether to display the image with annotations. |
| `line_thickness` | `int` | `2` | Thickness of the lines for drawing boxes and tracks. |
| `region_thickness` | `int` | `5` | Thickness of the region lines. |
| `spdl_dist_thresh` | `int` | `10` | Distance threshold for speed calculation. |
### Arguments `model.track`