Update Marker_Detection.md

This commit is contained in:
2026-11-23 12:51:13 +00:00
parent 1f4917bd38
commit ed6ab9f8e1
+9 -43
View File
@@ -1,10 +1,7 @@
# Marker Detection with YOLO26 on NVIDIA Jetson
End-to-end documentation: dataset creation, training, export and Jetson deployment.
> Items marked **[ ... ]** are still to be filled in. Screenshot notes are marked with 📷.
## 1. Project Overview
This project develops a custom **YOLO26** model to detect markers accurately in images and video streams. A dedicated marker dataset is used to train and evaluate the model. The trained model is deployed on an **NVIDIA Jetson Orin Nano** for efficient inference and real-time marker detection using GPU acceleration (TensorRT).
@@ -43,7 +40,7 @@ This project develops a custom **YOLO26** model to detect markers accurately in
| Training platform | Google Colab with GPU runtime |
| Annotation tool | **[ e.g., Roboflow / LabelImg / CVAT ]** |
| Export formats | ONNX, TensorRT (`.engine`) |
| Jetson OS | JetPack **[ version ]** |
| Jetson OS | JetPack |
| Languages / libraries | Python 3, Ultralytics, OpenCV, PyTorch |
## 3. Project Structure
@@ -80,49 +77,25 @@ The project lives on the Jetson at:
- different lighting (bright, dim, shadows)
- different backgrounds
- partial occlusion and motion blur
3. If using video, extract frames at a fixed interval:
```python
import cv2, os
video_path = "marker_video.mp4"
out_dir = "raw_images"
os.makedirs(out_dir, exist_ok=True)
cap = cv2.VideoCapture(video_path)
count, saved = 0, 0
while True:
ok, frame = cap.read()
if not ok:
break
if count % 10 == 0: # save every 10th frame
cv2.imwrite(f"{out_dir}/frame_{saved:05d}.jpg", frame)
saved += 1
count += 1
cap.release()
print("Saved frames:", saved)
```
**Total images collected:** [ ... ]
### 4.2 Annotate the Images
1. Upload the images to the annotation tool.
2. Create the class (for example `marker`) **[ confirm class name(s) ]**.
2. Create the class (for example `marker`).
3. Draw a tight bounding box around every marker in each image.
4. Review the labels and fix any inaccurate boxes.
📷 *Screenshot: annotation tool with bounding boxes*
### 4.3 Split the Dataset
The dataset was split into training, validation and test sets in a **70 / 20 / 10** ratio:
| Split | Share | Images |
| Split | Share |
|---|---|---|
| Train | 70% | [ ... ] |
| Validation | 20% | [ ... ] |
| Test | 10% | [ ... ] |
| Train | 70% |
| Validation | 20% |
| Test | 10% |
### 4.4 Export in YOLO Format
@@ -206,11 +179,10 @@ results = model.train(
| Parameter | Value used |
|---|---|
| Base model | [ yolo26n.pt ] |
| Epochs | [ ... ] |
| Image size | [ ... ] |
| Batch size | [ ... ] |
| Epochs | 100 |
| Image size | 416 |
| Batch size |16 |
📷 *Screenshot: training progress / epoch logs*
### 5.3 Locate the Trained Weights
@@ -246,7 +218,6 @@ print("Recall :", metrics.box.mr)
| mAP@50 | 0.9499 |
| mAP@50-95 | 0.6995 |
📷 *Screenshots: `results.png` (loss and metric curves), confusion matrix, PR curve*
### 6.3 Test on Sample Images
@@ -254,7 +225,6 @@ print("Recall :", metrics.box.mr)
results = model.predict(source="/content/dataset/images/test", conf=0.5, save=True)
```
📷 *Screenshot: sample predictions on test images*
## 7. Step 4 – Export to ONNX
@@ -271,7 +241,6 @@ model.export(format="onnx", imgsz=416)
This generates `marker_best.onnx` next to the `.pt` file.
📷 *Screenshot: successful export output*
> **Note:** the export image size (`imgsz`) should match the size used for inference on the Jetson (here, **416**).
@@ -329,7 +298,6 @@ This produces the following files in `models/`:
The `.engine` file is loaded automatically at inference time.
📷 *Screenshot: export finished with `.onnx` and `.engine` files listed*
> **Note:** a TensorRT engine is specific to the device and TensorRT version it was built on. Always build it on the Jetson itself.
@@ -344,7 +312,6 @@ python3 marker_detection.py --source 0 --imgsz 416
- `--source 0` selects the first camera (`/dev/video0`). A video file path can be used instead.
- `--imgsz 416` must match the size used during export.
📷 *Screenshot: live detection window with bounding boxes and confidence scores*
### 10.2 Monitor GPU Usage
@@ -374,7 +341,6 @@ python3 marker_tracking.py --source 0 --imgsz 416
The same TensorRT engine workflow is used: the engine is built once and loaded automatically at runtime.
📷 *Screenshot: tracking output with IDs on the markers*
## 12. Troubleshooting