BaseTrack: Move trivial values used in STrack to STrack
This commit is contained in:
1 parent
1f5b1c7e01
commit
e8983bf427
3 files changed
+7
-6
No files matched your search
@@ -1,8 +1,5 @@
|
||||
class BaseTrack:
|
||||
def __init__(self):
|
||||
self.is_activated = False
|
||||
|
||||
self.score = 0
|
||||
self.start_frame = 0
|
||||
self.frame_id = 0
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ class STrack(BaseTrack):
|
||||
):
|
||||
super().__init__()
|
||||
self.state = TrackState.New
|
||||
self.is_activated = False
|
||||
|
||||
self._tlwh = np.asarray(tlwh, dtype=np.float32)
|
||||
self.kalman_filter = None
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
from typing import List, Tuple
|
||||
from typing import TYPE_CHECKING, List, Tuple
|
||||
|
||||
import numpy as np
|
||||
from scipy.optimize import linear_sum_assignment
|
||||
|
||||
from supervision.detection.utils import box_iou_batch
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from supervision.tracker.byte_tracker.core import STrack
|
||||
|
||||
|
||||
def indices_to_matches(
|
||||
cost_matrix: np.ndarray, indices: np.ndarray, thresh: float
|
||||
@@ -53,11 +56,11 @@ def iou_distance(atracks: List, btracks: List) -> np.ndarray:
|
||||
return cost_matrix
|
||||
|
||||
|
||||
def fuse_score(cost_matrix: np.ndarray, detections: List) -> np.ndarray:
|
||||
def fuse_score(cost_matrix: np.ndarray, stracks: List["STrack"]) -> np.ndarray:
|
||||
if cost_matrix.size == 0:
|
||||
return cost_matrix
|
||||
iou_sim = 1 - cost_matrix
|
||||
det_scores = np.array([det.score for det in detections])
|
||||
det_scores = np.array([strack.score for strack in stracks])
|
||||
det_scores = np.expand_dims(det_scores, axis=0).repeat(cost_matrix.shape[0], axis=0)
|
||||
fuse_sim = iou_sim * det_scores
|
||||
fuse_cost = 1 - fuse_sim
|
||||
|
||||
Reference in new issue
Block a user