本文整理匯總了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