本文整理汇总了Python中table.Table.is_ball_in_hand方法的典型用法代码示例。如果您正苦于以下问题:Python Table.is_ball_in_hand方法的具体用法?Python Table.is_ball_in_hand怎么用?Python Table.is_ball_in_hand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类table.Table
的用法示例。
在下文中一共展示了Table.is_ball_in_hand方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_table
# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import is_ball_in_hand [as 别名]
def get_table(self):
size = self.original.shape
table = Table(size[0], size[1])
if self._is_ball_in_hand():
table.set_ball_in_hand(True)
table.set_hand(self._hand_pos)
circles = self.get_circles()
for c in circles[0,:]:
ball = ball_mod.Ball(
x=int(np.round(c[0])),
y=int(np.round(c[1])),
r=BALL_RADIUS)
if table.does_collide(ball):
continue
self._update_ball_detail(ball, table)
if ball.type == ball_mod.TYPE_PHANTOM:
continue
# if ball-in-hand, then make sure cue ball is right under the hand
# else it is a false positive match
if ball.type == ball_mod.TYPE_CUE and table.is_ball_in_hand():
x,y = table.get_hand()
d = ((x-ball.x)**2 + (y-ball.y)**2)**0.5
if d > BALL_RADIUS:
continue
table.add_ball(ball)
if self.debug:
colored = self.original.copy()
for b in table.get_balls():
if b.type == ball_mod.TYPE_CUE or b.type == ball_mod.TYPE_BLACK:
color = (0,0,255) # red
elif b.type == ball_mod.TYPE_STRIPE:
color = (0,255,0) # green
elif b.type == ball_mod.TYPE_SOLID:
color = (0,255,255) # yellow
cv2.circle(colored,(b.x, b.y), b.r,color,2)
cv2.circle(colored,(b.x, b.y),2,(0,0,255),3)
colored = cv2.cvtColor(colored, cv2.COLOR_BGR2RGB)
plt.subplot(2,1,1)
plt.imshow(colored)
plt.draw()
self.original = cv2.cvtColor(self.original, cv2.COLOR_BGR2RGB)
plt.subplot(2,1,2)
plt.imshow(self.original)
plt.draw()
plt.show(block=False)
# plt.show(block=True)
return table