当前位置:网站首页>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
边栏推荐
- newest! SASAC releases new measures for digital transformation of state-owned enterprises
- 关于ES6的新特性
- Dimension problems and contour lines
- How can chrome quickly transfer a group of web pages (tabs) to another device (computer)
- Livox SLAM(带LIO+闭环检测优化)
- O2O电商线上线下一体化模式分析
- DNA modified noble metal nanoparticles | DNA modified gold nanoparticles (scientific research level)
- Recommended by the world's most technologically competent smart contract security audit company in 2022
- 基于SSM医院预约管理系统
- Details of cross entropy loss function in pytorch
猜你喜欢

Express框架

Using docker to install and deploy redis on CentOS

Future, futuretask and completable future are often asked in interviews

工控用Web组态软件比组态软件更高效

DNA科研实验应用|环糊精修饰核酸CD-RNA/DNA|环糊精核酸探针/量子点核酸探针

Analysis of pix2pix principle

VIVO应用市场APP上架总结

Soul submitted an application for listing in Hong Kong stocks, accelerating the diversified and scene based layout of social gathering places

银行业客户体验管理现状与优化策略分析

Build cloud native operating environment
随机推荐
基于SSM医院预约管理系统
Redis operation of Linux Installation
大疆livox定制的格式CustomMsg格式转换pointcloud2
deepsort源码解读(五)
最新!国资委发布国有企业数字化转型新举措
Problems related to pytorch to onnx
Details of cross entropy loss function in pytorch
智能安防视频平台EasyCVR出现通道列表为空情况的原因是什么?
DNA coupled PbSe quantum dots | near infrared lead selenide PbSe quantum dots modified DNA | PbSe DNA QDs
Event capture and bubbling - what is the difference between them?
DNA偶联PbSe量子点|近红外硒化铅PbSe量子点修饰脱氧核糖核酸DNA|PbSe-DNA QDs
银行业客户体验管理现状与优化策略分析
事件捕获方式和冒泡方式—它们的区别是什么?
Cyclegan parsing
Sok: the faults in our asrs: an overview of attacks against automatic speech recognition
MangoDB
含有偶氮苯单体的肽核酸寡聚体(NH2-TNT4,N-PNAs)齐岳生物定制
[unity URP] the code obtains the universalrendererdata of the current URP configuration and dynamically adds the rendererfeature
【11】 Binary code: "holding two roller handcuffs, crying out for hot hot hot"?
Express framework