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:
parent
a2ecb24176
commit
2af71d15a6
134 changed files with 845 additions and 1020 deletions
|
|
@ -28,30 +28,23 @@ Queue management using [Ultralytics YOLOv8](https://github.com/ultralytics/ultra
|
|||
|
||||
```python
|
||||
import cv2
|
||||
from ultralytics import YOLO
|
||||
from ultralytics.solutions import queue_management
|
||||
from ultralytics import YOLO, solutions
|
||||
|
||||
model = YOLO("yolov8n.pt")
|
||||
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))
|
||||
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 = cv2.VideoWriter("queue_management.avi",
|
||||
cv2.VideoWriter_fourcc(*'mp4v'),
|
||||
fps,
|
||||
(w, h))
|
||||
video_writer = cv2.VideoWriter("queue_management.avi", cv2.VideoWriter_fourcc(*'mp4v'), fps, (w, h))
|
||||
|
||||
queue_region = [(20, 400), (1080, 404), (1080, 360), (20, 360)]
|
||||
|
||||
queue = queue_management.QueueManager()
|
||||
queue.set_args(classes_names=model.names,
|
||||
reg_pts=queue_region,
|
||||
line_thickness=3,
|
||||
fontsize=1.0,
|
||||
region_color=(255, 144, 31))
|
||||
queue = solutions.QueueManager(classes_names=model.names,
|
||||
reg_pts=queue_region,
|
||||
line_thickness=3,
|
||||
fontsize=1.0,
|
||||
region_color=(255, 144, 31))
|
||||
|
||||
while cap.isOpened():
|
||||
success, im0 = cap.read()
|
||||
|
|
@ -77,30 +70,23 @@ Queue management using [Ultralytics YOLOv8](https://github.com/ultralytics/ultra
|
|||
|
||||
```python
|
||||
import cv2
|
||||
from ultralytics import YOLO
|
||||
from ultralytics.solutions import queue_management
|
||||
from ultralytics import YOLO, solutions
|
||||
|
||||
model = YOLO("yolov8n.pt")
|
||||
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))
|
||||
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 = cv2.VideoWriter("queue_management.avi",
|
||||
cv2.VideoWriter_fourcc(*'mp4v'),
|
||||
fps,
|
||||
(w, h))
|
||||
video_writer = cv2.VideoWriter("queue_management.avi", cv2.VideoWriter_fourcc(*'mp4v'), fps, (w, h))
|
||||
|
||||
queue_region = [(20, 400), (1080, 404), (1080, 360), (20, 360)]
|
||||
|
||||
queue = queue_management.QueueManager()
|
||||
queue.set_args(classes_names=model.names,
|
||||
reg_pts=queue_region,
|
||||
line_thickness=3,
|
||||
fontsize=1.0,
|
||||
region_color=(255, 144, 31))
|
||||
queue = solutions.QueueManager(classes_names=model.names,
|
||||
reg_pts=queue_region,
|
||||
line_thickness=3,
|
||||
fontsize=1.0,
|
||||
region_color=(255, 144, 31))
|
||||
|
||||
while cap.isOpened():
|
||||
success, im0 = cap.read()
|
||||
|
|
@ -122,22 +108,22 @@ Queue management using [Ultralytics YOLOv8](https://github.com/ultralytics/ultra
|
|||
cv2.destroyAllWindows()
|
||||
```
|
||||
|
||||
### Optional Arguments `set_args`
|
||||
### Arguments `QueueManager`
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
|---------------------|-------------|----------------------------|---------------------------------------------|
|
||||
| `view_img` | `bool` | `False` | Display frames with counts |
|
||||
| `view_queue_counts` | `bool` | `True` | Display Queue counts only on video frame |
|
||||
| `line_thickness` | `int` | `2` | Increase bounding boxes thickness |
|
||||
| `reg_pts` | `list` | `[(20, 400), (1260, 400)]` | Points defining the Region Area |
|
||||
| `classes_names` | `dict` | `model.model.names` | Dictionary of Class Names |
|
||||
| `region_color` | `RGB Color` | `(255, 0, 255)` | Color of the Object counting Region or Line |
|
||||
| `track_thickness` | `int` | `2` | Thickness of Tracking Lines |
|
||||
| `draw_tracks` | `bool` | `False` | Enable drawing Track lines |
|
||||
| `track_color` | `RGB Color` | `(0, 255, 0)` | Color for each track line |
|
||||
| `count_txt_color` | `RGB Color` | `(255, 255, 255)` | Foreground color for Object counts text |
|
||||
| `region_thickness` | `int` | `5` | Thickness for object counter region or line |
|
||||
| `fontsize` | `float` | `0.6` | Font size of counting text |
|
||||
| Name | Type | Default | Description |
|
||||
|---------------------|------------------|----------------------------|-------------------------------------------------------------------------------------|
|
||||
| `classes_names` | `dict` | `model.names` | A dictionary mapping class IDs to class names. |
|
||||
| `reg_pts` | `list of tuples` | `[(20, 400), (1260, 400)]` | Points defining the counting region polygon. Defaults to a predefined rectangle. |
|
||||
| `line_thickness` | `int` | `2` | Thickness of the annotation lines. |
|
||||
| `track_thickness` | `int` | `2` | Thickness of the track lines. |
|
||||
| `view_img` | `bool` | `False` | Whether to display the image frames. |
|
||||
| `region_color` | `tuple` | `(255, 0, 255)` | Color of the counting region lines (BGR). |
|
||||
| `view_queue_counts` | `bool` | `True` | Whether to display the queue counts. |
|
||||
| `draw_tracks` | `bool` | `False` | Whether to draw tracks of the objects. |
|
||||
| `count_txt_color` | `tuple` | `(255, 255, 255)` | Color of the count text (BGR). |
|
||||
| `track_color` | `tuple` | `None` | Color of the tracks. If `None`, different colors will be used for different tracks. |
|
||||
| `region_thickness` | `int` | `5` | Thickness of the counting region lines. |
|
||||
| `fontsize` | `float` | `0.7` | Font size for the text annotations. |
|
||||
|
||||
### Arguments `model.track`
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue