Add random picking tables with plate prediction
This commit is contained in:
parent
f7f3e5de84
commit
68a554e57e
31
main.py
31
main.py
@ -21,6 +21,7 @@ if __name__ == "__main__":
|
|||||||
goal = None
|
goal = None
|
||||||
path = ''
|
path = ''
|
||||||
|
|
||||||
|
go = 0
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
@ -47,28 +48,34 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
if event.key == pygame.K_m:
|
if event.key == pygame.K_m:
|
||||||
|
|
||||||
tabPos = [[1, 2], [1, 4], [1, 5], [1, 7], [1, 8], [1, 10], [5, 4], [5, 8]]
|
tabPos = [[1, 2], [1, 5], [1, 8], [5, 8], [8, 2], [8, 5], [8, 8], [12, 3], [12, 7]]
|
||||||
print(tabPos[0][0], tabPos[0][1])
|
rand = randrange(8)
|
||||||
|
|
||||||
if not [waiter.X, waiter.Y] in tabPos:
|
if not [waiter.X, waiter.Y] in tabPos or go == 0:
|
||||||
|
if [waiter.X, waiter.Y] in tabPos:
|
||||||
|
model = 'waiter_' + waiter.direction
|
||||||
|
graphics.clear(waiter.X, waiter.Y - 1)
|
||||||
# save_dataset()
|
# save_dataset()
|
||||||
x = tabPos[0][0]
|
x = tabPos[rand][0]
|
||||||
y = tabPos[0][1]
|
y = tabPos[rand][1]
|
||||||
|
|
||||||
goal = (x, y)
|
goal = (x, y)
|
||||||
path = waiter.findPath(goal)
|
path = waiter.findPath(goal)
|
||||||
path = waiter.translatePath(path)
|
path = waiter.translatePath(path)
|
||||||
|
|
||||||
|
go = 1
|
||||||
else:
|
else:
|
||||||
predict = use_model_to_predict('test-{}'.format(randrange(20)))
|
predict = use_model_to_predict('test-{}'.format(rand))
|
||||||
|
|
||||||
if predict == 1:
|
if predict == 1:
|
||||||
predict = 'This plate is empty'
|
predict = 'EMPTY'
|
||||||
else:
|
else:
|
||||||
predict = 'This plate has food'
|
predict = 'FOOD'
|
||||||
text_speech('arialnarrow.ttf', 30, predict, (255, 255, 255), (0, 128, 0),
|
|
||||||
(waiter.X*100), (waiter.Y*50), False, False, screen=graphics.screen)
|
text_speech('arialnarrow.ttf', 25, predict, (255, 255, 255), (0, 128, 0),
|
||||||
|
(waiter.X * 50 + 25), (waiter.Y * 50 - 25), False, False, screen=graphics.screen)
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
|
go = 0
|
||||||
|
|
||||||
if event.key == pygame.K_r:
|
if event.key == pygame.K_r:
|
||||||
temp = False
|
temp = False
|
||||||
while not temp:
|
while not temp:
|
||||||
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 8.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 213 KiB After Width: | Height: | Size: 8.5 KiB |
@ -138,8 +138,8 @@ def use_model_to_predict(name):
|
|||||||
|
|
||||||
def text_speech(font: str, size: int, text: str, color, background, x, y, bold: bool, bubble: bool, screen):
|
def text_speech(font: str, size: int, text: str, color, background, x, y, bold: bool, bubble: bool, screen):
|
||||||
global textRect
|
global textRect
|
||||||
font = pygame.font.SysFont(None, 40)
|
font = pygame.font.SysFont(None, size)
|
||||||
# font = pygame.font.Font(font,size)
|
#font = pygame.font.Font(font, size)
|
||||||
font.set_bold(bold)
|
font.set_bold(bold)
|
||||||
textSurf = font.render(text, True, color).convert_alpha()
|
textSurf = font.render(text, True, color).convert_alpha()
|
||||||
if bubble:
|
if bubble:
|
||||||
|
Loading…
Reference in New Issue
Block a user