Simplify Solutions Docs code examples (#17493)
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
parent
7da74600ad
commit
cece2ee2cf
8 changed files with 74 additions and 501 deletions
|
|
@ -60,40 +60,18 @@ Monitoring workouts through pose estimation with [Ultralytics YOLO11](https://gi
|
|||
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))
|
||||
|
||||
gym = solutions.AIGym(
|
||||
model="yolo11n-pose.pt",
|
||||
show=True,
|
||||
kpts=[6, 8, 10],
|
||||
)
|
||||
|
||||
while cap.isOpened():
|
||||
success, im0 = cap.read()
|
||||
if not success:
|
||||
print("Video frame is empty or video processing has been successfully completed.")
|
||||
break
|
||||
im0 = gym.monitor(im0)
|
||||
|
||||
cv2.destroyAllWindows()
|
||||
```
|
||||
|
||||
=== "Workouts Monitoring with Save Output"
|
||||
|
||||
```python
|
||||
import cv2
|
||||
|
||||
from ultralytics import solutions
|
||||
|
||||
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))
|
||||
|
||||
# Video writer
|
||||
video_writer = cv2.VideoWriter("workouts.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))
|
||||
|
||||
# Init AIGym
|
||||
gym = solutions.AIGym(
|
||||
show=True,
|
||||
kpts=[6, 8, 10],
|
||||
show=True, # Display the frame
|
||||
kpts=[6, 8, 10], # keypoints index of person for monitoring specific exercise, by default it's for pushup
|
||||
model="yolo11n-pose.pt", # Path to the YOLO11 pose estimation model file
|
||||
# line_width=2, # Adjust the line width for bounding boxes and text display
|
||||
)
|
||||
|
||||
# Process video
|
||||
while cap.isOpened():
|
||||
success, im0 = cap.read()
|
||||
if not success:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue