本文整理汇总了Python中tracker.Tracker.transformCoordstoCV方法的典型用法代码示例。如果您正苦于以下问题:Python Tracker.transformCoordstoCV方法的具体用法?Python Tracker.transformCoordstoCV怎么用?Python Tracker.transformCoordstoCV使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracker.Tracker
的用法示例。
在下文中一共展示了Tracker.transformCoordstoCV方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from tracker import Tracker [as 别名]
# 或者: from tracker.Tracker import transformCoordstoCV [as 别名]
def main(ball):
c = Camera()
color = ball
log.info("Ball: " + color)
t = BallTracker(color)
ballpos = None
while ballpos is None:
frame = c.get_frame()
ballpos = t.getBallCoordinates(frame)
ballpos = Tracker.transformCoordstoDecartes(ballpos)
previous_positions = np.array([ballpos])
k = 20
while True:
frame = c.get_frame()
ballpos = t.getBallCoordinates(frame)
log.debug(ballpos)
if ballpos is None:
continue
ballpos = Tracker.transformCoordstoDecartes(ballpos)
previous_positions = np.append(previous_positions, [ballpos], axis=0)
last_k_positions = previous_positions[-k:]
direction_vector = linear_regression(last_k_positions)
direction_vector = [20 * x for x in direction_vector]
p1 = Tracker.transformCoordstoCV(round_point(ballpos))
p2 = Tracker.transformCoordstoCV(round_point(add_points(
ballpos, direction_vector)))
frame = cv2.circle(frame, p1, 20, (0, 0, 0), 2)
cv2.line(frame, p1, p2, (0, 255, 122), 2)
cv2.imshow('frame', frame)
l = cv2.waitKey(5) & 0xFF
if l == 27:
break
c.close()
cv2.destroyAllWindows()