This commit is contained in:
Lukas Wölfer
2019-04-22 22:20:26 +02:00
parent 5cca608962
commit 1ce1d55705
2 changed files with 11 additions and 8 deletions

View File

@@ -102,8 +102,8 @@ def find_square(search_square: np.ndarray,
best_square = square
best_count = count
best_coord = coord
assert best_square
assert best_coord
assert isinstance(best_square, np.ndarray)
assert isinstance(best_coord, tuple)
cv2.imshow("Window", best_square -
search_square[best_coord[0]:best_coord[0] +
best_square.shape[0], best_coord[1]:best_coord[1] +

View File

@@ -1,10 +1,11 @@
import itertools
from typing import Tuple, List, Dict
import numpy # type: ignore
import cv2 # type: ignore
from .context import shenzhen_solitaire
from shenzhen_solitaire.cv import adjustment
from shenzhen_solitaire.cv import card_finder
from typing import Tuple, List, Dict
import cv2
import numpy
import itertools
def pixelcount(image: numpy.ndarray) -> List[Tuple[Tuple[int, int, int], int]]:
@@ -18,6 +19,7 @@ def pixelcount(image: numpy.ndarray) -> List[Tuple[Tuple[int, int, int], int]]:
B = sorted(p.items(), key=lambda x: x[1])
return B
def simplify(image: numpy.ndarray) -> None:
cv2.imshow("Window", image)
cv2.waitKey(0)
@@ -46,7 +48,8 @@ def main() -> None:
for i in range(10, 20):
image_squares[i], _ = card_finder.simplify(image_squares[i])
print("Finding...")
found_image, certainty = card_finder.find_square(image_squares[i], squares)
found_image, certainty = card_finder.find_square(
image_squares[i], squares)
if __name__ == "__main__":