recognizer sie pierrdoli

This commit is contained in:
shaaqu 2020-06-09 21:57:37 +02:00
parent 5c0f2d5f15
commit e0613a5477
6 changed files with 15 additions and 25 deletions

View File

@ -1,25 +1,18 @@
import os import os
from codes_recognizer.rocognizer import recognizer from codes_recognizer.rocognizer import recognizer
from board import get_shelfs
def assigning(product_code_path, board, shelfs):
def assigning(product_code_path, shelfs):
c = None
code = recognizer(product_code_path) code = recognizer(product_code_path)
print(code)
product_color = str(code[0]) + str(code[1])
print(product_color)
for shelf in shelfs: for shelf in shelfs:
if shelf.is_empty: if shelf.color == product_color:
shelf.add_product(code) shelf.add_product(code)
c = shelf.get_coordinates() c = shelf.get_field()
break
else:
if shelf.get_product() == code:
shelf.add_product(code)
c = shelf.get_coordinates()
break
print("Product", product_code_path, "is on", c) print("Product", product_code_path, "is on", c)
return c return c

View File

@ -43,9 +43,9 @@ def recognizer(path):
probab = list(ps.numpy()[0]) probab = list(ps.numpy()[0])
code.append(probab.index(max(probab))) code.append(probab.index(max(probab)))
codes.append(code)
# cv2.imshow("Code", img) # cv2.imshow("Code", img)
# cv2.waitKey() # cv2.waitKey()
return codes return code

View File

@ -71,7 +71,7 @@ learning_data = [
['red', 'rectangle', 235, 'big', 'dr-Gerard-PryncyPalki'], ['red', 'rectangle', 235, 'big', 'dr-Gerard-PryncyPalki'],
['white', 'rectangle', 25, 'medium', 'Nestle-Cini-Minis-Batonik'], ['white', 'rectangle', 25, 'medium', 'Nestle-Cini-Minis-Batonik'],
['black', 'pack', 70, 'big', 'Korsarz-Draze'], ['black', 'pack', 70, 'big', 'Korsarz-Draze'],
['white', 'rectangle', 50, 'medium', 'Góralki'], ['white', 'rectangle', 50, 'medium', 'Goralki'],
['white', 'rectangle', 24, 'medium', 'Kinder-Country'], ['white', 'rectangle', 24, 'medium', 'Kinder-Country'],
['red', 'rectangle', 46, 'medium', '3Bit'], ['red', 'rectangle', 46, 'medium', '3Bit'],
['yellow', 'rectangle', 25, 'medium', 'Nestle-Nesquik-Batonik'], ['yellow', 'rectangle', 25, 'medium', 'Nestle-Nesquik-Batonik'],

View File

@ -78,7 +78,7 @@ def run():
Wyznacza patha do polki na ktora ma polozyc produkt. Wyznacza patha do polki na ktora ma polozyc produkt.
''' '''
# list [x, y] # list [x, y]
dest_shelf = new_product.shelf(board) dest_shelf = new_product.shelf(shelfs)
path = functions.a_star(board[agent.y][agent.x], dest_shelf.get_field(), board) path = functions.a_star(board[agent.y][agent.x], dest_shelf.get_field(), board)
'''''' ''''''

View File

@ -31,6 +31,6 @@ class FinalProduct:
self.img = create_image(self) self.img = create_image(self)
def shelf(self, board): def shelf(self, shelfs):
print(self.img) print(self.img)
return assigning(self.img, board); return assigning(self.img, shelfs);

View File

@ -19,11 +19,8 @@ class Shelf:
else: else:
self.level3.append(product) self.level3.append(product)
def get_product(self):
return self.products[0]
def get_field(self): def get_field(self):
return self.field return self.field
def get_color(self):
return self.color