当前位置:网站首页>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
边栏推荐
- Speech and language processing (3rd ed. draft) Chapter 2 - regular expression, text normalization, editing distance reading notes
- 基于SSM学生成绩管理系统
- 客户案例 | 聚焦流程体验,助银行企业APP迭代
- Many of the world's top 500 enterprises gathered at the second digital Expo, and the digital industry curtain is about to open!
- ES6 new features (getting started)
- regular expression
- 【Latex格式】双栏双图左右并排有小标题、上下并列有小标题
- deepsort源码解读(七)
- [unity URP] the code obtains the universalrendererdata of the current URP configuration and dynamically adds the rendererfeature
- 脱氧核糖核酸DNA修饰氧化锌|DNA修饰纳米金颗粒|DNA偶联修饰碳纳米材料
猜你喜欢

Image super-resolution evaluation index

Build cloud native operating environment

ZnS-DNA QDs近红外硫化锌ZnS量子点改性脱氧核糖核酸DNA|DNA修饰ZnS量子点

强网杯2021 pwn 赛题解析——babypwn

Why can cross entropy loss be used to characterize loss

基于SSM音乐网站管理系统

ES6 new features (getting started)

ES6新特性(入门)

DNA (deoxyribonucleic acid) supply | carbon nanotube nucleic acid loaded dna/rna material | dna/rna nucleic acid modified magnetic nanoparticles

Boostrap
随机推荐
Customer cases | focus on process experience to help bank enterprise app iteration
Disk management and file system
运行代码报错: libboost_filesystem.so.1.58.0: cannot open shared object file: No such file or directory
How to make the minimum API bind the array in the query string
Sunflower popularizes Science in an all-round way to avoid loopholes for your remote control equipment in time
关于卡尔曼滤波的协方差如何影响deepsort的跟踪效果的考虑
基于SSM实现的校园新闻发布管理系统
After adding a camera (camera) to the UAV in gazebo, the UAV cannot take off
How to delete or replace the loading style of easyplayer streaming media player?
AI:业余时间打比赛—挣它个小小目标—【阿里安全×ICDM 2022】大规模电商图上的风险商品检测比赛
PNA肽核酸修饰多肽Suc-Tyr-Leu-Val-pNA|Suc-Ala-Pro-Phe-pNA 11
Significance of NVIDIA SMI parameters
Speech and language processing (3rd ed. draft) Chapter 2 - regular expression, text normalization, editing distance reading notes
基于SSM学生成绩管理系统
硫化镉CdS量子点修饰脱氧核糖核酸DNA|CdS-DNA QDs|近红外CdS量子点偶联DNA规格信息
MangoDB
Shell programming specifications and variables
Many of the world's top 500 enterprises gathered at the second digital Expo, and the digital industry curtain is about to open!
如何删除或替换EasyPlayer流媒体播放器的loading样式?
Memo @restcontrolleradvice and exception interception class example