本文整理汇总了Python中Point.Point.update_last_seen_position方法的典型用法代码示例。如果您正苦于以下问题:Python Point.update_last_seen_position方法的具体用法?Python Point.update_last_seen_position怎么用?Python Point.update_last_seen_position使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point.Point
的用法示例。
在下文中一共展示了Point.update_last_seen_position方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LaserMote
# 需要导入模块: from Point import Point [as 别名]
# 或者: from Point.Point import update_last_seen_position [as 别名]
#.........这里部分代码省略.........
Finds contour and determines if it's valid laser dot or not through area threshold.
Displays debug text and draws a circle on detected laser point.
:param laser: image containing only laser dot (i.e image within our threshold).
:param frame: frame to display and writing debug text on.
:return: frame.
"""
contours, hierarchy = cv2.findContours(
laser, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
found_valid_point = False
for cnt in contours:
area = cv2.contourArea(cnt)
M = cv2.moments(cnt)
# check if the contour is withing the area threshold
if self.min_area < area < self.max_area:
cx = int(M['m10'] / M['m00'])
cy = int(M['m01'] / M['m00'])
# if self.debug:
# print "within threshold " + str(area)
if self.point.was_seen() \
: # and self.get_distance(cx, cy) <= self.distance_threshold:
if self.debug:
print "[DEBUG] Distance between last seen point ({0},{1})" \
" and current point ({2},{3}) :{4}".format(str(self.point.last_seen_x),
str(self.point.last_seen_y),
str(cx), str(cy),
str(self.get_distance(cx, cy)))
# update last point locations
self.point.update_last_seen_position(cx, cy)
self.point.set_on()
self.point.current_object = self.is_dot_within_rois(cx, cy)
# cv2.drawContours(frame, cnt, -1, GREEN, 15) # draws the contour
cv2.circle(frame, (cx, cy), 1, GREEN, thickness=4, lineType=8, shift=0) # circle cnt center
elif not self.point.was_seen():
# cv2.drawContours(frame, cnt, -1, BLUE, 15) # draws the contour
self.point.set_on()
self.point.update_last_seen_position(cx, cy)
self.point.current_object = self.is_dot_within_rois(cx, cy)
if self.debug:
print '[DEBUG] First seen point is at: ({0},{1}).'.format(str(cx), str(cy))
print '[DEBUG] Updated last seen coordinates.'
cv2.putText(
frame,
self.debug_text(cx, cy, area, found=True), LaserMote.BOTTOM_LEFT_COORD,
cv2.FONT_HERSHEY_SIMPLEX, 0.5, WHITE, 1)
found_valid_point = True
break # only one contour
if not found_valid_point:
cv2.putText(frame, self.debug_text(),
LaserMote.BOTTOM_LEFT_COORD, cv2.FONT_HERSHEY_SIMPLEX, 0.5, WHITE, 1)
if self.point.is_on() and self.point.was_seen():
current_object = self.is_dot_within_rois(self.point.last_seen_x, self.point.last_seen_y)
self.point.set_off(current_object)