You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The objects I'm tracking all look the same, but I want to identify them differently, but I can't figure it out. I'd like to ask for advice.
import cv2
import torch
from ultralytics import YOLO
from deep_sort_pytorch.utils.parser import get_config
from deep_sort_pytorch.deep_sort import DeepSort
import numpy as np
YOLOv8 모델 로드
model = YOLO("C:/Users/Pc/Downloads/person.v7i.yolov8/best.pt")
Programming HelpProgramming languages, open source, and software development.
1 participant
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Body
The objects I'm tracking all look the same, but I want to identify them differently, but I can't figure it out. I'd like to ask for advice.
import cv2
import torch
from ultralytics import YOLO
from deep_sort_pytorch.utils.parser import get_config
from deep_sort_pytorch.deep_sort import DeepSort
import numpy as np
YOLOv8 모델 로드
model = YOLO("C:/Users/Pc/Downloads/person.v7i.yolov8/best.pt")
DeepSORT 설정
cfg = get_config()
cfg.merge_from_file("C:/Users/Pc/Downloads/person.v7i.yolov8/deep_sort_pytorch/configs/deep_sort.yaml")
deepsort = DeepSort(
"C:/Users/Pc/Downloads/person.v7i.yolov8/deep_sort_pytorch/deep_sort/deep/checkpoint/ckpt.t7",
max_dist=cfg.DEEPSORT.MAX_DIST,
max_iou_distance=cfg.DEEPSORT.MAX_IOU_DISTANCE,
max_age=cfg.DEEPSORT.MAX_AGE,
n_init=cfg.DEEPSORT.N_INIT,
nn_budget=cfg.DEEPSORT.NN_BUDGET,
use_cuda=True
)
고정 색상 매핑 (ID 1~5)
TRACK_COLORS = {
1: (255, 0, 0), # 파랑
2: (0, 255, 0), # 초록
3: (0, 0, 255), # 빨강
4: (255, 255, 0), # 노랑
5: (255, 0, 255) # 핑크
}
비디오 로드
cap = cv2.VideoCapture("C:/Users/Pc/Downloads/person.v7i.yolov8/way.mp4")
if not cap.isOpened():
print("Error: Cannot open video file.")
exit()
객체 ID와 색상을 매핑하기 위한 딕셔너리
track_id_to_color = {}
while True:
ret, frame = cap.read()
if not ret:
print("End of video.")
break
cap.release()
cv2.destroyAllWindows()
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions