From c0c216e9297752d7151b7b918538d91a43c90af7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20W=C3=B6lfer?= Date: Sun, 23 Jun 2019 17:35:34 +0200 Subject: [PATCH] Merged loop --- shenzhen_solitaire/cv/adjustment.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/shenzhen_solitaire/cv/adjustment.py b/shenzhen_solitaire/cv/adjustment.py index 1890739..a2fafbd 100644 --- a/shenzhen_solitaire/cv/adjustment.py +++ b/shenzhen_solitaire/cv/adjustment.py @@ -2,6 +2,7 @@ from typing import Optional, Tuple from dataclasses import dataclass +import itertools import numpy import cv2 @@ -35,13 +36,12 @@ def _adjust_squares( adjustment = Adjustment(0, 0, 0, 0, 0, 0) while True: working_image = image.copy() - for index_x in range(count_x): - for index_y in range(count_y): - square = get_square(adjustment, index_x, index_y) - cv2.rectangle(working_image, - (square[0], square[1]), - (square[2], square[3]), - (0, 0, 0)) + for index_x, index_y in itertools.product(range(count_x), range(count_y)): + square = get_square(adjustment, index_x, index_y) + cv2.rectangle(working_image, + (square[0], square[1]), + (square[2], square[3]), + (0, 0, 0)) cv2.imshow('Window', working_image) k = cv2.waitKey(0) print(k)