Files
Project_documents/04_pose_estimation_README.md
2026-11-23 11:42:41 +05:30

107 lines
3.7 KiB
Markdown

# Task 04: Pose Estimation Using Python
## Task Title
Pose Estimation Using Python
## Description
Implement and test the `04_pose_estimation.py` script on the Jetson Orin Nano. Runs YOLO26n-pose to detect people and their 17 body keypoints (nose, eyes, ears, shoulders, elbows, wrists, hips, knees, ankles) and draws the skeleton on screen.
## When to Use
Use this for human activity analysis, fitness or posture checks, gesture-based control, and fall detection.
## Hardware and Software
- Device: NVIDIA Jetson Orin Nano (JetPack with CUDA and TensorRT)
- Camera: USB webcam (for example Logitech BRIO 100) at CAMERA_INDEX 0
- Language: Python 3
- Model: YOLO26 (Ultralytics), weights `yolo26n-pose.pt`
- Libraries: ultralytics, opencv-python, numpy
## Installation
```
pip install ultralytics opencv-python
```
On Jetson, install the JetPack-matched PyTorch and torchvision builds first (see the Ultralytics Jetson guide in the references). Model weights download automatically on first run if the machine is online.
## Command to Run
```
python3 04_pose_estimation.py
```
Check the camera is visible before running:
```
ls /dev/video*
```
## How It Works
1. Load the pose weights (yolo26n-pose.pt).
2. Open the camera feed (or an input image or video).
3. Run the model on each frame.
4. Read keypoints and confidences from the result.
5. Draw the keypoints and connecting skeleton lines, plus FPS. Press Q to quit.
## Settings You Can Change
Edit these values at the top of the script:
- CAMERA_INDEX, FRAME_W, FRAME_H : camera options
- CONF_THRESHOLD : minimum person confidence
- Keypoint confidence limit for drawing a joint, if defined
- MODEL_WEIGHTS = yolo26n-pose.pt
## Controls
- Press `Q` to quit the live window
## Verify the Output
Run `python3 04_pose_estimation.py` and confirm:
- [ ] A live window opens and a skeleton is drawn on each person.
- [ ] Joints move smoothly with the body.
- [ ] Keypoints are visible for the whole body when the person is fully in frame.
- [ ] Q closes the window.
## Optional: Faster Inference with TensorRT
For higher FPS on the Orin Nano, export the model to a TensorRT engine once and point `MODEL_WEIGHTS` to the engine file:
```
yolo export model=yolo26n-pose.pt format=engine half=True
```
Then set `MODEL_WEIGHTS = 'yolo26n-pose.engine'` in the script.
## Troubleshooting
- Camera not opening: check `ls /dev/video*`, try CAMERA_INDEX 1, and make sure no other app is using the camera.
- Window does not show over SSH: run on the Jetson desktop, or use X11 forwarding.
- Low FPS: use the nano model, lower FRAME_W / FRAME_H, run `sudo nvpmodel -m 0` and `sudo jetson_clocks`, or export to TensorRT.
- Weights not found: connect to the internet for the first run or copy the .pt file next to the script.
- Out of memory: close other apps and reduce the input size.
## How This Differs From the Other Tasks
Finds body joints, whereas 01 to 03 only find objects or shapes.
Files in this folder: 01_detection, 02_tracking, 03_segmentation, 04_pose_estimation, 05_classification, 06_roi_detection, 07_obb_detection, 08_depth_estimation.
## References
- [Pose estimation task docs](https://docs.ultralytics.com/tasks/pose/)
- [COCO keypoints dataset](https://docs.ultralytics.com/datasets/pose/coco/)
- [Workouts monitoring solution](https://docs.ultralytics.com/guides/workouts-monitoring/)
- [Ultralytics YOLO26 model page](https://docs.ultralytics.com/models/yolo26/)
- [Ultralytics on NVIDIA Jetson guide](https://docs.ultralytics.com/guides/nvidia-jetson/)
- [TensorRT export](https://docs.ultralytics.com/integrations/tensorrt/)
- [Ultralytics GitHub](https://github.com/ultralytics/ultralytics)
- [JetPack SDK](https://developer.nvidia.com/embedded/jetpack)