Added new pictures
BIN
Solitaire.png
|
Before Width: | Height: | Size: 521 KiB |
BIN
Solitaire2.png
|
Before Width: | Height: | Size: 1.0 MiB |
BIN
pictures/20190809172206_1.jpg
Executable file
|
After Width: | Height: | Size: 642 KiB |
BIN
pictures/20190809172213_1.jpg
Executable file
|
After Width: | Height: | Size: 636 KiB |
BIN
pictures/20190809172219_1.jpg
Executable file
|
After Width: | Height: | Size: 633 KiB |
BIN
pictures/20190809172225_1.jpg
Executable file
|
After Width: | Height: | Size: 633 KiB |
BIN
pictures/20190809172232_1.jpg
Executable file
|
After Width: | Height: | Size: 636 KiB |
BIN
pictures/20190809172238_1.jpg
Executable file
|
After Width: | Height: | Size: 639 KiB |
@@ -38,12 +38,16 @@ class Configuration:
|
|||||||
for square, card in self.catalogue:
|
for square, card in self.catalogue:
|
||||||
counter += 1
|
counter += 1
|
||||||
file_stream = io.BytesIO()
|
file_stream = io.BytesIO()
|
||||||
np.save(file_stream, card_finder.simplify(square)[0], allow_pickle=False)
|
np.save(
|
||||||
|
file_stream,
|
||||||
|
card_finder.simplify(square)[0],
|
||||||
|
allow_pickle=False)
|
||||||
file_name = ""
|
file_name = ""
|
||||||
if isinstance(card, board.SpecialCard):
|
if isinstance(card, board.SpecialCard):
|
||||||
file_name = f's{card.value}-{card.name}-{counter}.npy'
|
file_name = f's{card.value}-{card.name}-{counter}.npy'
|
||||||
elif isinstance(card, board.NumberCard):
|
elif isinstance(card, board.NumberCard):
|
||||||
file_name = f'n{card.suit.value}{card.number}-{card.suit.name}-{counter}.npy'
|
file_name = f'n{card.suit.value}{card.number}'\
|
||||||
|
f'-{card.suit.name}-{counter}.npy'
|
||||||
else:
|
else:
|
||||||
raise AssertionError()
|
raise AssertionError()
|
||||||
zip_file.writestr(
|
zip_file.writestr(
|
||||||
@@ -72,7 +76,8 @@ class Configuration:
|
|||||||
catalogue: List[Tuple[np.ndarray, board.Card]] = []
|
catalogue: List[Tuple[np.ndarray, board.Card]] = []
|
||||||
with zipfile.ZipFile(filename, 'r') as zip_file:
|
with zipfile.ZipFile(filename, 'r') as zip_file:
|
||||||
adj = adjustment.Adjustment(
|
adj = adjustment.Adjustment(
|
||||||
**json.loads(zip_file.read(Configuration.ADJUSTMENT_FILE_NAME)))
|
**json.loads(
|
||||||
|
zip_file.read(Configuration.ADJUSTMENT_FILE_NAME)))
|
||||||
for template_filename in (
|
for template_filename in (
|
||||||
x for x in zip_file.namelist() if
|
x for x in zip_file.namelist() if
|
||||||
x.startswith(Configuration.TEMPLATES_DIRECTORY + '/')):
|
x.startswith(Configuration.TEMPLATES_DIRECTORY + '/')):
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from shenzhen_solitaire.cv.configuration import Configuration
|
|||||||
|
|
||||||
def generate() -> None:
|
def generate() -> None:
|
||||||
"""Generate a configuration"""
|
"""Generate a configuration"""
|
||||||
with open("Solitaire.png", 'rb') as png_file:
|
with open("pictures/20190809172213_1.jpg", 'rb') as png_file:
|
||||||
img_str = png_file.read()
|
img_str = png_file.read()
|
||||||
nparr = np.frombuffer(img_str, np.uint8)
|
nparr = np.frombuffer(img_str, np.uint8)
|
||||||
image = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
|
image = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
|
||||||
@@ -19,13 +19,14 @@ def generate() -> None:
|
|||||||
generated_config = Configuration.generate(image)
|
generated_config = Configuration.generate(image)
|
||||||
generated_config.save('test_config.zip')
|
generated_config.save('test_config.zip')
|
||||||
|
|
||||||
|
|
||||||
def parse() -> board.Board:
|
def parse() -> board.Board:
|
||||||
"""Parse a configuration"""
|
"""Parse a configuration"""
|
||||||
with open("Solitaire2.png", 'rb') as png_file:
|
with open("pictures/20190809172213_1.jpg", 'rb') as png_file:
|
||||||
img_str = png_file.read()
|
img_str = png_file.read()
|
||||||
nparr = np.frombuffer(img_str, np.uint8)
|
nparr = np.frombuffer(img_str, np.uint8)
|
||||||
image = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
|
image = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
|
||||||
image = cv2.resize(image, (1000, 629))
|
# image = cv2.resize(image, (1000, 629))
|
||||||
|
|
||||||
loaded_config = Configuration.load('test_config.zip')
|
loaded_config = Configuration.load('test_config.zip')
|
||||||
loaded_config.field_adjustment = adjustment.adjust_field(image)
|
loaded_config.field_adjustment = adjustment.adjust_field(image)
|
||||||
|
|||||||