Skip to content

Commit

Permalink
Merge pull request #68 from NUTFes/feat/ycn/issue66
Browse files Browse the repository at this point in the history
Feat/ycn/issue66
  • Loading branch information
nose221834 authored Aug 22, 2024
2 parents c5eaa1f + 661d048 commit 1db4d9d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Binary file not shown.
9 changes: 6 additions & 3 deletions yolo_fine_tuning/src/yolo_motion_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
PATH = HOME_DIR + "/yolo_fine_tuning/runs/detect/train14/weights/best.pt"

# 動画ファイルのパス
video_path = VIDEO_PATH = HOME_DIR + "/yolo_fine_tuning/src/testVideo/tra-pa_motion_test.mp4"
video_path = VIDEO_PATH = HOME_DIR + "/yolo_fine_tuning/src/testVideo/tra-pa_motion_test_multi.mp4"

# Yoloモデルのロード
model = YOLO(PATH)
Expand All @@ -26,11 +26,13 @@
ret, frame = cap.read()
if ret:
# フレームごとに物体検知を行う
results = model(frame)
results = model.track(frame, persist=True)

# 検知結果を描画
annotated_frame = results[0].plot()

idList = list(map(int, results[0].boxes.id)) if results[0].boxes.id is not None else []
print("id: ", idList)

# 出力動画にフレームを書き込む
out.write(annotated_frame)

Expand All @@ -43,6 +45,7 @@
else:
break


# リソースの解放
cap.release()
out.release()
Expand Down

0 comments on commit 1db4d9d

Please sign in to comment.