diff --git a/nestris_ocr/calibration/auto_number.py b/nestris_ocr/calibration/auto_number.py index 7b55989..c2d0c62 100644 --- a/nestris_ocr/calibration/auto_number.py +++ b/nestris_ocr/calibration/auto_number.py @@ -17,7 +17,6 @@ def track_best_result(lowestScore, bestRect, result): def auto_adjust_numrect(capture_coords, rect, numDigits, updateUI): - pattern = "D" * numDigits i = 0 diff --git a/nestris_ocr/calibration/number_chooser.py b/nestris_ocr/calibration/number_chooser.py index 92412ce..e40324f 100644 --- a/nestris_ocr/calibration/number_chooser.py +++ b/nestris_ocr/calibration/number_chooser.py @@ -35,7 +35,6 @@ def __init__(self, root, name, defaultValue, isFloat, OnChange, minCrement): ).grid(row=1, column=3, sticky="nsew") def changeValueText(self): - success, value = self.checker(self.value.get()) if success: self.OnChange(value) diff --git a/nestris_ocr/calibration/widgets.py b/nestris_ocr/calibration/widgets.py index 235dbf4..b3d112a 100644 --- a/nestris_ocr/calibration/widgets.py +++ b/nestris_ocr/calibration/widgets.py @@ -11,6 +11,5 @@ def __init__(self, *args, **kwargs): super(Button, self).__init__(*args, **kwargs) - else: from tkinter import Button diff --git a/nestris_ocr/capturing/deinterlacer.py b/nestris_ocr/capturing/deinterlacer.py index f7885b0..66a8c25 100644 --- a/nestris_ocr/capturing/deinterlacer.py +++ b/nestris_ocr/capturing/deinterlacer.py @@ -108,7 +108,6 @@ def deinterlace_np(img): # de-interlaces a PIL.Image def deinterlace(img): - mode, res = get_mode_res() full_size = list(img.size) diff --git a/nestris_ocr/capturing/file.py b/nestris_ocr/capturing/file.py index 4e7b26c..9b85a76 100644 --- a/nestris_ocr/capturing/file.py +++ b/nestris_ocr/capturing/file.py @@ -23,7 +23,6 @@ def __init__(self, source_id: str, xywh_box: XYWHBox, extra_data: str) -> None: self.total_frames = int(self.cap.get(cv2.CAP_PROP_FRAME_COUNT)) def get_image(self, rgb: bool = False) -> Tuple[float, Image.Image]: - if not self.cap: return None, None diff --git a/nestris_ocr/capturing/opencv/opencv.py b/nestris_ocr/capturing/opencv/opencv.py index ef30d3e..bd4b783 100644 --- a/nestris_ocr/capturing/opencv/opencv.py +++ b/nestris_ocr/capturing/opencv/opencv.py @@ -99,7 +99,6 @@ def get_image(self, rgb: bool = False) -> Tuple[float, Image.Image]: image_ts = self.image_ts if rgb: - cv2_image = cv2.cvtColor(cv2_image, cv2.COLOR_BGR2RGB) image = Image.fromarray(cv2_image).crop(xywh_to_ltrb(self.xywh_box)) @@ -124,7 +123,6 @@ def update(self): frame_times = deque([], 10) start_frame_ts = None while self.running: - cv2_retval, cv2_image = self.cap.read() avg_ft = self.calculate_avg_frametime(frame_times, start_frame_ts) start_frame_ts = time.time() diff --git a/nestris_ocr/network/autobahn_client.py b/nestris_ocr/network/autobahn_client.py index aca7396..28c44a2 100644 --- a/nestris_ocr/network/autobahn_client.py +++ b/nestris_ocr/network/autobahn_client.py @@ -44,7 +44,6 @@ def CreateClient(target, port): class MyClientProtocol(WebSocketClientProtocol): - connections = [] def onConnect(self, response): @@ -87,7 +86,6 @@ def close_all(cls): class MyClientFactory(WebSocketClientFactory, ReconnectingClientFactory): - protocol = MyClientProtocol closing = False kickMessage = None @@ -108,7 +106,7 @@ def __init__(self, target, port): super().__init__() self.port = port self.host = target - self.factory = MyClientFactory(u"ws://" + target + ":" + str(port)) + self.factory = MyClientFactory("ws://" + target + ":" + str(port)) # reactor thread def run(self): diff --git a/nestris_ocr/network/autobahn_server.py b/nestris_ocr/network/autobahn_server.py index b4d6531..238c40d 100644 --- a/nestris_ocr/network/autobahn_server.py +++ b/nestris_ocr/network/autobahn_server.py @@ -98,7 +98,7 @@ def __init__(self, target, port): print( "Warning, starting up autobahn_server with target not equal to localhost" ) - self.url = u"ws://" + target + ":" + str(port) + self.url = "ws://" + target + ":" + str(port) self.protocol = OCRServer self.running = False @@ -132,14 +132,13 @@ def stop(self): if __name__ == "__main__": - import sys from twisted.python import log log.startLogging(sys.stdout) - factory = WebSocketServerFactory(u"ws://127.0.0.1:3338") + factory = WebSocketServerFactory("ws://127.0.0.1:3338") factory.protocol = MyServerProtocol reactor.listenTCP(3338, factory) diff --git a/nestris_ocr/network/native_fieldpacker.cp311-win_amd64.pyd b/nestris_ocr/network/native_fieldpacker.cp311-win_amd64.pyd new file mode 100644 index 0000000..61d5b8e Binary files /dev/null and b/nestris_ocr/network/native_fieldpacker.cp311-win_amd64.pyd differ diff --git a/nestris_ocr/network/native_fieldpacker.cp37-win32.pyd b/nestris_ocr/network/native_fieldpacker.cp37-win32.pyd deleted file mode 100644 index 02642fb..0000000 Binary files a/nestris_ocr/network/native_fieldpacker.cp37-win32.pyd and /dev/null differ diff --git a/nestris_ocr/network/tcp_client.py b/nestris_ocr/network/tcp_client.py index d1f1eea..3f74647 100644 --- a/nestris_ocr/network/tcp_client.py +++ b/nestris_ocr/network/tcp_client.py @@ -39,7 +39,6 @@ def run(self): # Create a socket (SOCK_STREAM means a TCP socket) while not self.stopped(): with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: - sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, True) sock.settimeout(TIME_OUT) try: diff --git a/nestris_ocr/ocr_algo/board2.py b/nestris_ocr/ocr_algo/board2.py index d103587..68fb8b8 100644 --- a/nestris_ocr/ocr_algo/board2.py +++ b/nestris_ocr/ocr_algo/board2.py @@ -34,7 +34,6 @@ def match_color(pixr, pixg, pixb, colors): cache=True, ) def shine_parse(img, colors_bw, colors_noblack): - # todo: maybe pass this in as a 3d array instead, # as numba hates python arrays colors_noblack_remap = [1, 2, 3] @@ -100,7 +99,6 @@ def shine_parse(img, colors_bw, colors_noblack): cache=True, ) def ao9_parse(img, colors): - # todo: maybe pass this in as a 3d array instead, # as numba hates python arrays diff --git a/nestris_ocr/ocr_algo/board_ocr.cp311-win_amd64.pyd b/nestris_ocr/ocr_algo/board_ocr.cp311-win_amd64.pyd new file mode 100644 index 0000000..495bf3f Binary files /dev/null and b/nestris_ocr/ocr_algo/board_ocr.cp311-win_amd64.pyd differ diff --git a/nestris_ocr/ocr_algo/build_fastboard.py b/nestris_ocr/ocr_algo/build_fastboard.py index 76c1145..8c9822a 100644 --- a/nestris_ocr/ocr_algo/build_fastboard.py +++ b/nestris_ocr/ocr_algo/build_fastboard.py @@ -29,7 +29,6 @@ def match_color(pixr, pixg, pixb, colors): @cc.export("shine_parse", "uint8[:,:](uint8[:,:,:],uint8[:,:],uint8[:,:])") def shine_parse(img, colors_bw, colors_noblack): - # todo: maybe pass this in as a 3d array instead, # as numba hates python arrays colors_noblack_remap = [1, 2, 3] @@ -91,7 +90,6 @@ def shine_parse(img, colors_bw, colors_noblack): @cc.export("ao9_parse", "uint8[:,:](uint8[:,:,:],uint8[:,:])") def ao9_parse(img, colors): - # todo: maybe pass this in as a 3d array instead, # as numba hates python arrays diff --git a/nestris_ocr/ocr_algo/digit.py b/nestris_ocr/ocr_algo/digit.py index 7b6a961..48647b2 100644 --- a/nestris_ocr/ocr_algo/digit.py +++ b/nestris_ocr/ocr_algo/digit.py @@ -36,9 +36,7 @@ def setupColour(prefix, outputDict, digitList): img = img.convert("L") if IMAGE_MULT != 1: - img = img.resize( - (SCALED_IMAGE_SIZE, SCALED_IMAGE_SIZE), PIL.Image.LANCZOS - ) + img = img.resize((SCALED_IMAGE_SIZE, SCALED_IMAGE_SIZE), PIL.Image.LANCZOS) img = img.getdata() img = np.asarray(img) @@ -107,7 +105,7 @@ def scoreImage0(img, digitPattern): count = len(digitPattern) img = convertImg(img, count, False) - for (i, pattern) in enumerate(digitPattern): + for i, pattern in enumerate(digitPattern): result = getDigit(img, pattern, i * (BLOCK_SIZE * IMAGE_MULT), 0, False) if result[0] == "null": return None @@ -121,7 +119,7 @@ def scoreImage(img, digitPattern, show=False, red=False): count = len(digitPattern) img = convertImg(img, count, show) label = "" - for (i, pattern) in enumerate(digitPattern): + for i, pattern in enumerate(digitPattern): if pattern == "X": result = "X" else: diff --git a/nestris_ocr/ocr_state/field_state.py b/nestris_ocr/ocr_state/field_state.py index 3cfc79d..03ced78 100644 --- a/nestris_ocr/ocr_state/field_state.py +++ b/nestris_ocr/ocr_state/field_state.py @@ -2,6 +2,7 @@ from nestris_ocr.config import config # TODO: remove this dependency. from nestris_ocr.network.byte_stuffer import prePackField + # Todo: numba optimize for numTiles # Make sure we account for rotating piece above field, as this reduces # Blockcount by 2 diff --git a/nestris_ocr/scan_strat/scan_helpers.py b/nestris_ocr/scan_strat/scan_helpers.py index d584580..b267454 100644 --- a/nestris_ocr/scan_strat/scan_helpers.py +++ b/nestris_ocr/scan_strat/scan_helpers.py @@ -149,7 +149,6 @@ def scan_black_n_white(full_image): for x in range(img_bnw_mono.width): for y in range(img_bnw_mono.height): - value = img_bnw_mono.getpixel((x, y)) if value > whitest: diff --git a/requirements.txt b/requirements.txt index 0e326e1..8f165af 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,11 @@ -autobahn[twisted] -cached-property -numba -numpy -opencv-python -pillow -pre-commit -websockets +autobahn[twisted]==23.6.2 +cached-property==1.5.2 +numba==0.58.1 +numpy==1.26.2 +opencv-python==4.8.1.78 +pillow==10.1.0 +pre-commit==3.6.0 +websockets==12.0 pyobjc; sys_platform == "darwin" pypiwin32; sys_platform == "win32" tkmacosx; sys_platform == "darwin" diff --git a/scripts/build-windows/requirements.txt b/scripts/build-windows/requirements.txt index 33291e9..ada2b4d 100644 --- a/scripts/build-windows/requirements.txt +++ b/scripts/build-windows/requirements.txt @@ -1,16 +1,15 @@ -autobahn[twisted] -cached-property -numba==0.50.1 -https://download.lfd.uci.edu/pythonlibs/w3jqiv8s/numpy-1.18.5+vanilla-cp37-cp37m-win32.whl; sys_platform == "win32" -opencv-python-headless -pillow -pre-commit -websockets +autobahn[twisted]==23.6.2 +cached-property==1.5.2 +numba==0.58.1 +numpy==1.26.2 +opencv-python-headless==4.8.1.78 +pillow==10.1.0 +pre-commit==3.6.0 +websockets==12.0 pyobjc; sys_platform == "darwin" pypiwin32; sys_platform == "win32" tkmacosx; sys_platform == "darwin" -setuptools==44.0.0 -pyinstaller==3.6 -zip-files -gitchangelog -pystache +pyinstaller==5.13.1 +zip-files==0.4.1 +gitchangelog==3.0.4 +pystache==0.6.5 \ No newline at end of file