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
|
|
@ -42,8 +42,7 @@ Measuring the gap between two objects is known as distance calculation within a
|
|||
=== "Video Stream"
|
||||
|
||||
```python
|
||||
from ultralytics import YOLO
|
||||
from ultralytics.solutions import distance_calculation
|
||||
from ultralytics import YOLO, solutions
|
||||
import cv2
|
||||
|
||||
model = YOLO("yolov8n.pt")
|
||||
|
|
@ -54,14 +53,10 @@ Measuring the gap between two objects is known as distance calculation within a
|
|||
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("distance_calculation.avi",
|
||||
cv2.VideoWriter_fourcc(*'mp4v'),
|
||||
fps,
|
||||
(w, h))
|
||||
video_writer = cv2.VideoWriter("distance_calculation.avi", cv2.VideoWriter_fourcc(*'mp4v'), fps, (w, h))
|
||||
|
||||
# Init distance-calculation obj
|
||||
dist_obj = distance_calculation.DistanceCalculation()
|
||||
dist_obj.set_args(names=names, view_img=True)
|
||||
dist_obj = solutions.DistanceCalculation(names=names, view_img=True)
|
||||
|
||||
while cap.isOpened():
|
||||
success, im0 = cap.read()
|
||||
|
|
@ -84,15 +79,16 @@ Measuring the gap between two objects is known as distance calculation within a
|
|||
- Mouse Right Click will delete all drawn points
|
||||
- Mouse Left Click can be used to draw points
|
||||
|
||||
### Optional Arguments `set_args`
|
||||
### Arguments `DistanceCalculation()`
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
|------------------|--------|-----------------|--------------------------------------------------------|
|
||||
| `names` | `dict` | `None` | Classes names |
|
||||
| `view_img` | `bool` | `False` | Display frames with counts |
|
||||
| `line_thickness` | `int` | `2` | Increase bounding boxes thickness |
|
||||
| `line_color` | `RGB` | `(255, 255, 0)` | Line Color for centroids mapping on two bounding boxes |
|
||||
| `centroid_color` | `RGB` | `(255, 0, 255)` | Centroid color for each bounding box |
|
||||
| `Name` | `Type` | `Default` | Description |
|
||||
|--------------------|---------|-----------------|-----------------------------------------------------------|
|
||||
| `names` | `dict` | `None` | Dictionary mapping class indices to class names. |
|
||||
| `pixels_per_meter` | `int` | `10` | Conversion factor from pixels to meters. |
|
||||
| `view_img` | `bool` | `False` | Flag to indicate if the video stream should be displayed. |
|
||||
| `line_thickness` | `int` | `2` | Thickness of the lines drawn on the image. |
|
||||
| `line_color` | `tuple` | `(255, 255, 0)` | Color of the lines drawn on the image (BGR format). |
|
||||
| `centroid_color` | `tuple` | `(255, 0, 255)` | Color of the centroids drawn (BGR format). |
|
||||
|
||||
### Arguments `model.track`
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue