本文整理匯總了Python中rect.Rect.asNumpyArray方法的典型用法代碼示例。如果您正苦於以下問題:Python Rect.asNumpyArray方法的具體用法?Python Rect.asNumpyArray怎麽用?Python Rect.asNumpyArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rect.Rect
的用法示例。
在下文中一共展示了Rect.asNumpyArray方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: evaluateFrame
# 需要導入模塊: from rect import Rect [as 別名]
# 或者: from rect.Rect import asNumpyArray [as 別名]
def evaluateFrame(self, frame):
"""Update statistics by evaluating a new frame."""
timestamp = frame["timestamp"]
groundtruths = frame["annotations"]
hypotheses = self.get_hypotheses_frame(timestamp)["hypotheses"]
visualDebugAnnotations = []
# Save occuring ground truth ids
for g in groundtruths:
self.groundtruth_ids_.add(g["id"])
# Save occuring hypothesis ids
for h in hypotheses:
self.hypothesis_ids_.add(h["id"])
rospy.logdebug("")
rospy.logdebug("Timestamp: %s" % timestamp)
rospy.logdebug("DIFF")
rospy.logdebug("DIFF Time %.2f" % timestamp)
logstr = ["DIFF Mappings:"]
for gt_id in sorted(self.mappings_.keys()):
logstr.append("%s-%s" % (gt_id, self.mappings_[gt_id]))
rospy.logdebug(" ".join(logstr))
# No need to evaluate this frame.
if len(groundtruths) == 0 and len(hypotheses) == 0:
rospy.logdebug("No gt and hypos for this frame.")
return
rospy.logdebug("GTs:")
for groundtruth in groundtruths:
rospy.logdebug(Rect(groundtruth))
rospy.logdebug("Hypos:")
for hypothesis in hypotheses:
rospy.logdebug(Rect(hypothesis))
# PAPER STEP 1
# Valid mappings skip Munkres algorithm, if both ground truth and hypo are found in this frame
# We call these pairs correspondences and fill the list each frame.
correspondences = {} # truth id -> hypothesis id
listofprints = []
rospy.logdebug("")
rospy.logdebug("STEP 1: KEEP CORRESPONDENCE")
# print "DIFF Keep correspondence"
for gt_id in self.mappings_.keys():
groundtruth = filter(lambda g: g["id"] == gt_id, groundtruths) # Get ground truths with given ground truth id in current frame
if len(groundtruth) > 1:
rospy.logwarn("found %d > 1 ground truth tracks for id %s", len(groundtruth), gt_id)
elif len(groundtruth) < 1:
continue
hypothesis = filter(lambda h: h["id"] == self.mappings_[gt_id], hypotheses) # Get hypothesis with hypothesis id according to mapping
assert len(hypothesis) <= 1
if len(hypothesis) != 1:
continue
# Hypothesis found for known mapping
# Check hypothesis for overlap
distance = numpy.linalg.norm(Rect(groundtruth[0]).asNumpyArray() - Rect(hypothesis[0]).asNumpyArray() )
if distance <= self.matching_threshold_:
rospy.logdebug("Keeping correspondence between %s and %s" % (groundtruth[0]["id"], hypothesis[0]["id"]))
# print "DIFF Keep corr %s %s %.2f" % (groundtruth[0]["id"], hypothesis[0]["id"], Rect(groundtruth[0]).overlap(Rect(hypothesis[0])))
#listofprints.append("DIFF Keep corr %s %s %.2f" % (groundtruth[0]["id"], hypothesis[0]["id"], Rect(groundtruth[0]).overlap(Rect(hypothesis[0]))))
correspondences[gt_id] = hypothesis[0]["id"]
self.total_distance_ += distance
for p in sorted(listofprints):
rospy.logdebug(p)
# PAPER STEP 2
rospy.logdebug("")
rospy.logdebug("STEP 2: FIND CORRESPONDENCE")
# Fill hungarian matrix with +inf
munkres_matrix = [ [ self.munkres_inf_ for i in range(len(hypotheses)) ] for j in range(len(groundtruths)) ] # TODO make square matrix
# Find correspondences
for i in range(len(groundtruths)):
groundtruth = groundtruths[i]
# Skip groundtruth with correspondence from mapping
if groundtruth["id"] in correspondences.keys():
rospy.logdebug("Groundtruth %s already in correspondence" % groundtruth["id"])
continue
# Fill hungarian matrix with distance between gts and hypos
for j in range(len(hypotheses)):
hypothesis = hypotheses[j]
# Skip hypotheses with correspondence from mapping
if hypothesis["id"] in correspondences.values():
#.........這裏部分代碼省略.........