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