当前位置:网站首页>Interpretation of deepsort source code (II)
Interpretation of deepsort source code (II)
2022-07-27 07:02:00 【Delin enbao】
Catalog
deepsort Principle and analysis summary
iou_matching.py
# vim: expandtab:ts=4:sw=4
from __future__ import absolute_import
import numpy as np
from . import linear_assignment
def iou(bbox, candidates):
"""Computer intersection over union.
Parameters
----------
bbox : ndarray
A bounding box in format `(top left x, top left y, width, height)`.
candidates : ndarray
A matrix of candidate bounding boxes (one per row) in the same format
as `bbox`.
Returns
-------
ndarray
The intersection over union in [0, 1] between the `bbox` and each
candidate. A higher score means a larger fraction of the `bbox` is
occluded by the candidate.
"""
bbox_tl, bbox_br = bbox[:2], bbox[:2] + bbox[2:]
candidates_tl = candidates[:, :2]
candidates_br = candidates[:, :2] + candidates[:, 2:]
tl = np.c_[np.maximum(bbox_tl[0], candidates_tl[:, 0])[:, np.newaxis],
np.maximum(bbox_tl[1], candidates_tl[:, 1])[:, np.newaxis]]
br = np.c_[np.minimum(bbox_br[0], candidates_br[:, 0])[:, np.newaxis],
np.minimum(bbox_br[1], candidates_br[:, 1])[:, np.newaxis]]
wh = np.maximum(0., br - tl)
area_intersection = wh.prod(axis=1)
area_bbox = bbox[2:].prod()
area_candidates = candidates[:, 2:].prod(axis=1)
return area_intersection / (area_bbox + area_candidates - area_intersection)
def iou_cost(tracks, detections, track_indices=None,
detection_indices=None):
"""An intersection over union distance metric.
Parameters
----------
tracks : List[deep_sort.track.Track]
A list of tracks.
detections : List[deep_sort.detection.Detection]
A list of detections.
track_indices : Optional[List[int]]
A list of indices to tracks that should be matched. Defaults to
all `tracks`.
detection_indices : Optional[List[int]]
A list of indices to detections that should be matched. Defaults
to all `detections`.
Returns
-------
ndarray
Returns a cost matrix of shape
len(track_indices), len(detection_indices) where entry (i, j) is
`1 - iou(tracks[track_indices[i]], detections[detection_indices[j]])`.
"""
if track_indices is None:
track_indices = np.arange(len(tracks))
if detection_indices is None:
detection_indices = np.arange(len(detections))
cost_matrix = np.zeros((len(track_indices), len(detection_indices)))
for row, track_idx in enumerate(track_indices):
# take time_since_update=1 Of track Assign infinite cost
if tracks[track_idx].time_since_update > 1:
cost_matrix[row, :] = linear_assignment.INFTY_COST
continue
bbox = tracks[track_idx].to_tlwh()
candidates = np.asarray([detections[i].tlwh for i in detection_indices])
# Calculation track With all the unmatched_detections Of iou cost
cost_matrix[row, :] = 1. - iou(bbox, candidates)
return cost_matrix
边栏推荐
- Create a container that does not depend on any underlying image
- 如何让最小 API 绑定查询字符串中的数组
- EasyCVR平台播放设备录像时,拖动时间轴播放无效是什么原因?
- Peptide nucleic acid oligomer containing azobenzene monomer (nh2-tnt4, n-pnas) Qiyue biological customization
- Reasoning speed of model
- O2O电商线上线下一体化模式分析
- 采用QT进行OpenGL开发(一)绘制平面图形
- vscode运行命令报错:标记“&&”不是此版本中的有效语句分隔符。
- 聊聊大火的多模态
- 工控用Web组态软件比组态软件更高效
猜你喜欢

Px4 source code compilation to establish its own program module

CentOS上使用Docker安装和部署Redis

PNA肽核酸修饰多肽Suc-Tyr-Leu-Val-pNA|Suc-Ala-Pro-Phe-pNA 11

PNA polypeptide PNA TPP | GLT ala ala Pro Leu PNA | suc ala Pro PNA | suc AAPL PNA | suc AAPM PNA

About the new features of ES6

脱氧核糖核酸DNA改性近红外二区砷化镓GaAs量子点|GaAs-DNA QDs|DNA修饰GaAs量子点

MangoDB

Auto encoder (AE), denoising auto encoder (DAE), variable auto encoder (VAE) differences

Significance of NVIDIA SMI parameters

What "hard core innovations" does Intel have in the first half of 2022? Just look at this picture!
随机推荐
大疆livox定制的格式CustomMsg格式转换pointcloud2
Details of cross entropy loss function in pytorch
Problems related to pytorch to onnx
C语言怎么学?这篇文章给你完整答案
齐岳:巯基修饰寡聚DNA|DNA修饰CdTe/CdS核壳量子点|DNA偶联砷化铟InAs量子点InAs-DNA QDs
MangoDB
The problem of torch loading custom models
EasyRecovery14数据恢复软件官方功能简介
ZnS-DNA QDs近红外硫化锌ZnS量子点改性脱氧核糖核酸DNA|DNA修饰ZnS量子点
Create a container that does not depend on any underlying image
基于SSM学生学籍管理系统
After adding a camera (camera) to the UAV in gazebo, the UAV cannot take off
Account management and authority
CentOS上使用Docker安装和部署Redis
To improve the baby's allergy, take yiminshu. Azg and aibeca love la Beijia work together to protect the growth of Chinese babies
Iotdb C client release 0.13.0.7
Recommended by the world's most technologically competent smart contract security audit company in 2022
Problems related to compilation and training of Darknet yolov3 and Yolo fast using CUDA environment of rtx30 Series graphics card on win10 platform
DNA科研实验应用|环糊精修饰核酸CD-RNA/DNA|环糊精核酸探针/量子点核酸探针
MangoDB