mirror of
https://github.com/THU-MIG/yolov10.git
synced 2025-05-23 13:34:23 +08:00
Add polygon regions drawing support in object-counting.md
and minor docs update (#8885)
This commit is contained in:
parent
3623d62ea8
commit
014f0b4b8d
@ -36,7 +36,7 @@ Object counting with [Ultralytics YOLOv8](https://github.com/ultralytics/ultraly
|
|||||||
|
|
||||||
!!! Example "Object Counting using YOLOv8 Example"
|
!!! Example "Object Counting using YOLOv8 Example"
|
||||||
|
|
||||||
=== "Region"
|
=== "Count in Region"
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from ultralytics import YOLO
|
from ultralytics import YOLO
|
||||||
@ -79,7 +79,50 @@ Object counting with [Ultralytics YOLOv8](https://github.com/ultralytics/ultraly
|
|||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
```
|
```
|
||||||
|
|
||||||
=== "Line"
|
=== "Count in Polygon"
|
||||||
|
|
||||||
|
```python
|
||||||
|
from ultralytics import YOLO
|
||||||
|
from ultralytics.solutions import object_counter
|
||||||
|
import cv2
|
||||||
|
|
||||||
|
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))
|
||||||
|
|
||||||
|
# Define region points as a polygon with 5 points
|
||||||
|
region_points = [(20, 400), (1080, 404), (1080, 360), (20, 360), (20, 400)]
|
||||||
|
|
||||||
|
# Video writer
|
||||||
|
video_writer = cv2.VideoWriter("object_counting_output.avi",
|
||||||
|
cv2.VideoWriter_fourcc(*'mp4v'),
|
||||||
|
fps,
|
||||||
|
(w, h))
|
||||||
|
|
||||||
|
# Init Object Counter
|
||||||
|
counter = object_counter.ObjectCounter()
|
||||||
|
counter.set_args(view_img=True,
|
||||||
|
reg_pts=region_points,
|
||||||
|
classes_names=model.names,
|
||||||
|
draw_tracks=True)
|
||||||
|
|
||||||
|
while cap.isOpened():
|
||||||
|
success, im0 = cap.read()
|
||||||
|
if not success:
|
||||||
|
print("Video frame is empty or video processing has been successfully completed.")
|
||||||
|
break
|
||||||
|
tracks = model.track(im0, persist=True, show=False)
|
||||||
|
|
||||||
|
im0 = counter.start_counting(im0, tracks)
|
||||||
|
video_writer.write(im0)
|
||||||
|
|
||||||
|
cap.release()
|
||||||
|
video_writer.release()
|
||||||
|
cv2.destroyAllWindows()
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "Count in Line"
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from ultralytics import YOLO
|
from ultralytics import YOLO
|
||||||
|
@ -69,6 +69,7 @@ Explore the YOLOv8 Docs, a comprehensive resource designed to help you understan
|
|||||||
- [YOLOv6](https://github.com/meituan/YOLOv6) was open-sourced by [Meituan](https://about.meituan.com/) in 2022 and is in use in many of the company's autonomous delivery robots.
|
- [YOLOv6](https://github.com/meituan/YOLOv6) was open-sourced by [Meituan](https://about.meituan.com/) in 2022 and is in use in many of the company's autonomous delivery robots.
|
||||||
- [YOLOv7](https://github.com/WongKinYiu/yolov7) added additional tasks such as pose estimation on the COCO keypoints dataset.
|
- [YOLOv7](https://github.com/WongKinYiu/yolov7) added additional tasks such as pose estimation on the COCO keypoints dataset.
|
||||||
- [YOLOv8](https://github.com/ultralytics/ultralytics) is the latest version of YOLO by Ultralytics. As a cutting-edge, state-of-the-art (SOTA) model, YOLOv8 builds on the success of previous versions, introducing new features and improvements for enhanced performance, flexibility, and efficiency. YOLOv8 supports a full range of vision AI tasks, including [detection](tasks/detect.md), [segmentation](tasks/segment.md), [pose estimation](tasks/pose.md), [tracking](modes/track.md), and [classification](tasks/classify.md). This versatility allows users to leverage YOLOv8's capabilities across diverse applications and domains.
|
- [YOLOv8](https://github.com/ultralytics/ultralytics) is the latest version of YOLO by Ultralytics. As a cutting-edge, state-of-the-art (SOTA) model, YOLOv8 builds on the success of previous versions, introducing new features and improvements for enhanced performance, flexibility, and efficiency. YOLOv8 supports a full range of vision AI tasks, including [detection](tasks/detect.md), [segmentation](tasks/segment.md), [pose estimation](tasks/pose.md), [tracking](modes/track.md), and [classification](tasks/classify.md). This versatility allows users to leverage YOLOv8's capabilities across diverse applications and domains.
|
||||||
|
- [YOLOv9] (https://github.com/WongKinYiu/yolov9) Introduces innovative methods like Programmable Gradient Information (PGI) and the Generalized Efficient Layer Aggregation Network (GELAN).
|
||||||
|
|
||||||
## YOLO Licenses: How is Ultralytics YOLO licensed?
|
## YOLO Licenses: How is Ultralytics YOLO licensed?
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user