本文整理汇总了Python中deep_sort.detection.Detection方法的典型用法代码示例。如果您正苦于以下问题:Python detection.Detection方法的具体用法?Python detection.Detection怎么用?Python detection.Detection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类deep_sort.detection
的用法示例。
在下文中一共展示了detection.Detection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_detections
# 需要导入模块: from deep_sort import detection [as 别名]
# 或者: from deep_sort.detection import Detection [as 别名]
def create_detections(detection_mat, frame_idx, min_height=0):
"""Create detections for given frame index from the raw detection matrix.
Parameters
----------
detection_mat : ndarray
Matrix of detections. The first 10 columns of the detection matrix are
in the standard MOTChallenge detection format. In the remaining columns
store the feature vector associated with each detection.
frame_idx : int
The frame index.
min_height : Optional[int]
A minimum detection bounding box height. Detections that are smaller
than this value are disregarded.
Returns
-------
List[tracker.Detection]
Returns detection responses at given frame index.
"""
frame_indices = detection_mat[:, 0].astype(np.int)
mask = frame_indices == frame_idx
detection_list = []
for row in detection_mat[mask]:
bbox, confidence, feature = row[2:6], row[6], row[10:]
if bbox[3] < min_height:
continue
detection_list.append(Detection(bbox, confidence, feature))
return detection_list
示例2: parse_args
# 需要导入模块: from deep_sort import detection [as 别名]
# 或者: from deep_sort.detection import Detection [as 别名]
def parse_args():
""" Parse command line arguments.
"""
parser = argparse.ArgumentParser(description="Deep SORT")
parser.add_argument(
"--sequence_dir", help="Path to MOTChallenge sequence directory",
default=None, required=True)
parser.add_argument(
"--detection_file", help="Path to custom detections.", default=None,
required=True)
parser.add_argument(
"--output_file", help="Path to the tracking output file. This file will"
" contain the tracking results on completion.",
default="/tmp/hypotheses.txt")
parser.add_argument(
"--min_confidence", help="Detection confidence threshold. Disregard "
"all detections that have a confidence lower than this value.",
default=0.8, type=float)
parser.add_argument(
"--min_detection_height", help="Threshold on the detection bounding "
"box height. Detections with height smaller than this value are "
"disregarded", default=0, type=int)
parser.add_argument(
"--nms_max_overlap", help="Non-maxima suppression threshold: Maximum "
"detection overlap.", default=1.0, type=float)
parser.add_argument(
"--max_cosine_distance", help="Gating threshold for cosine distance "
"metric (object appearance).", type=float, default=0.2)
parser.add_argument(
"--nn_budget", help="Maximum size of the appearance descriptors "
"gallery. If None, no budget is enforced.", type=int, default=None)
parser.add_argument(
"--display", help="Show intermediate tracking results",
default=True, type=bool_string)
return parser.parse_args()
示例3: create_obj_infos
# 需要导入模块: from deep_sort import detection [as 别名]
# 或者: from deep_sort.detection import Detection [as 别名]
def create_obj_infos(cur_frame, final_boxes, final_probs, final_labels,
box_feats, targetid2class, tracking_objs, min_confidence,
min_detection_height, scale, is_coco_model=False,
coco_to_actev_mapping=None):
obj_infos = []
tracking_boxes = final_boxes / scale
for j, (box, prob, label) in enumerate(zip(tracking_boxes, final_probs, final_labels)):
cat_name = targetid2class[label]
if is_coco_model:
if cat_name not in coco_to_actev_mapping:
continue
else:
cat_name = coco_to_actev_mapping[cat_name]
confidence_socre = float(round(prob, 7))
if cat_name not in tracking_objs or confidence_socre < min_confidence:
continue
box[2] -= box[0]
box[3] -= box[1]
avg_feat = box_feats[j]
if len(avg_feat.shape) > 2:
avg_feat = np.mean(np.mean(box_feats[j], axis=1), axis=1)
norm_feat = avg_feat / np.linalg.norm(avg_feat)
list_feat = norm_feat.tolist()
bbox_data = [cur_frame, box[0], box[1], box[2], box[3], confidence_socre] + list_feat
obj_infos.append(bbox_data)
detections = []
for row in obj_infos:
bbox, confidence, feature = row[1:5], row[5], row[6:]
if bbox[3] < min_detection_height:
continue
detections.append(Detection(bbox, confidence, feature))
return detections
# 1
示例4: create_detections
# 需要导入模块: from deep_sort import detection [as 别名]
# 或者: from deep_sort.detection import Detection [as 别名]
def create_detections(self, bboxes, feature):
detections = []
for box in np.array(bboxes):
if box is None or len(box) == 0:
continue
box[2:4] -= box[:2]
# too small to do reid
if box[2] < self.conf.min_width and box[3] < self.conf.min_height:
continue
detections.append(Detection(tlwh=box[:4], confidence=box[4], feature=[]))
return detections