initial commit
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
# Task 07: Oriented Bounding Box (OBB) Detection Using Python
|
||||
|
||||
## Task Title
|
||||
|
||||
Oriented Bounding Box (OBB) Detection Using Python
|
||||
|
||||
## Description
|
||||
|
||||
Implement and test the `07_obb_detection.py` script on the Jetson Orin Nano. Runs YOLO26n-obb to detect objects with rotated bounding boxes that follow the object's angle instead of a straight rectangle.
|
||||
|
||||
## When to Use
|
||||
|
||||
Use this for objects that appear at any angle, such as aerial or satellite images, ships, vehicles, parts on a conveyor or tilted text and tools.
|
||||
|
||||
## 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-obb.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 07_obb_detection.py
|
||||
```
|
||||
|
||||
Check the camera is visible before running:
|
||||
|
||||
```
|
||||
ls /dev/video*
|
||||
```
|
||||
|
||||
## How It Works
|
||||
|
||||
1. Load the OBB weights (yolo26n-obb.pt).
|
||||
2. Open the camera feed or an input image or video.
|
||||
3. Run the model on each frame.
|
||||
4. Read the rotated box corners, class and confidence from the result.
|
||||
5. Draw the rotated polygons with labels and 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 : detection threshold
|
||||
- MODEL_WEIGHTS = yolo26n-obb.pt
|
||||
- Input size, normally 1024 for the DOTA-trained model
|
||||
|
||||
## Controls
|
||||
|
||||
- Press `Q` to quit the live window
|
||||
|
||||
## Verify the Output
|
||||
|
||||
Run `python3 07_obb_detection.py` and confirm:
|
||||
|
||||
- [ ] Rotated boxes are drawn that tilt with the object.
|
||||
- [ ] Labels show class and confidence.
|
||||
- [ ] The default model is trained on DOTA aerial classes, so use aerial images for the best test; 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-obb.pt format=engine half=True
|
||||
```
|
||||
|
||||
Then set `MODEL_WEIGHTS = 'yolo26n-obb.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
|
||||
|
||||
Boxes carry an angle, unlike the axis-aligned boxes in 01_detection.
|
||||
|
||||
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
|
||||
|
||||
- [Oriented bounding boxes task docs](https://docs.ultralytics.com/tasks/obb/)
|
||||
- [DOTA v1 dataset](https://docs.ultralytics.com/datasets/obb/dota-v2/)
|
||||
- [Ultralytics YOLO26 model page](https://docs.ultralytics.com/models/yolo26/)
|
||||
- [DOTA dataset site](https://captain-whu.github.io/DOTA/)
|
||||
- [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)
|
||||
Reference in New Issue
Block a user