Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing byte track through example in notebook with car video #18

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# CHANGELOG



## v0.2.0 (2023-12-22)

### Feature

* feat: allow python 3.11 (#17) ([`2515015`](https://github.com/artefactory-fr/bytetrack/commit/25150157967432f9986103aeb7ab03671653ffb1))

* feat: allow python 3.11 (#16)

Co-authored-by: TomDarmon <[email protected]>
Co-authored-by: github-actions <[email protected]> ([`c9442e3`](https://github.com/artefactory-fr/bytetrack/commit/c9442e30811b5479520ad8695706d0da8ce09397))

* feat: allow python 3.11 (#14)

Co-authored-by: TomDarmon <[email protected]>
Co-authored-by: github-actions <[email protected]> ([`e8c77a0`](https://github.com/artefactory-fr/bytetrack/commit/e8c77a04138214022a3823637869f58851a5f8ef))


## v0.1.0 (2023-12-19)

### Feature
Expand All @@ -16,6 +35,7 @@

* Tp/add reset (#10) ([`074bb18`](https://github.com/artefactory-fr/bytetrack/commit/074bb18424f7670b0d26d945fa1fefc97faed041))


## v0.0.3 (2023-11-24)

### Fix
Expand All @@ -26,20 +46,22 @@

* Hotfix/frame id in update (#8) ([`1aaeb78`](https://github.com/artefactory-fr/bytetrack/commit/1aaeb780420c84857b14597083afc8692b16962f))

* fix frame_id in update instead of_ ([`aafc3b7`](https://github.com/artefactory-fr/bytetrack/commit/aafc3b7d7be40534a6e88628302b9478991f533c))
* fix frame_id in update instead of _ ([`aafc3b7`](https://github.com/artefactory-fr/bytetrack/commit/aafc3b7d7be40534a6e88628302b9478991f533c))


## v0.0.2 (2023-11-13)

### Fix

* fix: cython (#6)

Co-authored-by: TomDarmon &lt;<[email protected]>&gt; ([`553d5c1`](https://github.com/artefactory-fr/bytetrack/commit/553d5c192b6d1414e30dcd5701ea95cd761205bb))
Co-authored-by: TomDarmon &lt;[email protected]&gt; ([`553d5c1`](https://github.com/artefactory-fr/bytetrack/commit/553d5c192b6d1414e30dcd5701ea95cd761205bb))

### Unknown

* Fix: cython release (#7) ([`d145ef6`](https://github.com/artefactory-fr/bytetrack/commit/d145ef6511c63b9b6fc6e0c6073249320e0d5861))


## v0.0.1 (2023-11-13)

### Fix
Expand Down
5 changes: 5 additions & 0 deletions examples/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
git+https://github.com/artefactory-fr/bytetrack.git@main
git+https://github.com/artefactory-fr/track-reid.git@main
opencv-python==4.8.1.78
ultralytics==8.0.216
matplotlib==3.8.2
420 changes: 420 additions & 0 deletions examples/test_bytetrack_car.ipynb

Large diffs are not rendered by default.

70 changes: 70 additions & 0 deletions examples/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import cv2
import numpy as np


def draw_all_bbox_on_image(image, tracking_objects: np.ndarray):
"""
A list of of detections with track id, class id and confidence.
[
[x, y, x, y, track_id, class_id, conf],
[x, y, x, y, track_id, class_id, conf],
...
]

Plot this on the image with the track id, class id and confidence.
"""
for detection in tracking_objects:
x1, y1, x2, y2, track_id, _, conf = detection
x1, y1, x2, y2 = int(x1), int(y1), int(x2), int(y2)
cv2.rectangle(image, (x1, y1), (x2, y2), (255, 0, 0), 2)
cv2.putText(
image,
f"{int(track_id)} ({conf:.2f})",
(x1, y1 - 10),
0,
1,
(0, 255, 0),
2,
)
return image


def yolo_results_to_bytetrack_format(detections):
"""Transforms YOLO detections into the bytetrack format.

Args:
detections: A list of YOLO detections.

Returns:
A list of bytetrack detections.
"""
boxes = detections.numpy().boxes.xyxyn
scores = detections.numpy().boxes.conf
classes = detections.numpy().boxes.cls
return np.stack(
[
boxes[:, 0],
boxes[:, 1],
boxes[:, 2],
boxes[:, 3],
scores,
classes,
],
axis=1,
)


def scale_bbox_as_xyxy(bbox: np.ndarray, target_img_size: tuple):
"""Scales a bounding box to a target image size.

Args:
bbox: A bounding box in the format [x, y, x, y].
target_img_size: The target image size as a tuple (h, W).

Returns:
The scaled bounding box.
"""
x1, y1, x2, y2 = bbox
h, w = target_img_size
scaled_bbox = np.array([x1 * w, y1 * h, x2 * w, y2 * h])
return scaled_bbox
Binary file added examples/yolov8m.pt
Binary file not shown.
Loading