This commit is contained in:
Maxim Devaev 2024-07-08 05:37:53 +03:00
parent 237d39b172
commit ea285e3fec
2 changed files with 4 additions and 4 deletions

View File

@ -145,12 +145,12 @@ class Ocr:
if left < right and top < bottom: if left < right and top < bottom:
image_cropped = image.crop((left, top, right, bottom)) image_cropped = image.crop((left, top, right, bottom))
image.close() image.close()
image = image_cropped image = image_cropped # type: ignore
ImageOps.grayscale(image) ImageOps.grayscale(image)
image_resized = image.resize((int(image.size[0] * 2), int(image.size[1] * 2)), PilImage.Resampling.BICUBIC) image_resized = image.resize((int(image.size[0] * 2), int(image.size[1] * 2)), PilImage.Resampling.BICUBIC)
image.close() image.close()
image = image_resized image = image_resized # type: ignore
_libtess.TessBaseAPISetImage(api, image.tobytes("raw", "RGB"), image.width, image.height, 3, image.width * 3) _libtess.TessBaseAPISetImage(api, image.tobytes("raw", "RGB"), image.width, image.height, 3, image.width * 3)
text_ptr = None text_ptr = None

View File

@ -120,8 +120,8 @@ class _SpiPhy(BasePhy): # pylint: disable=too-many-instance-attributes
return os.path.exists(f"/dev/spidev{self.__bus}.{self.__chip}") return os.path.exists(f"/dev/spidev{self.__bus}.{self.__chip}")
@contextlib.contextmanager @contextlib.contextmanager
def connected(self) -> Generator[_SpiPhyConnection, None, None]: # pylint: disable=contextmanager-generator-missing-cleanup # type: ignore def connected(self) -> Generator[_SpiPhyConnection, None, None]: # type: ignore
with self.__sw_cs_connected() as switch_cs: with self.__sw_cs_connected() as switch_cs: # pylint: disable=contextmanager-generator-missing-cleanup
with contextlib.closing(spidev.SpiDev(self.__bus, self.__chip)) as spi: with contextlib.closing(spidev.SpiDev(self.__bus, self.__chip)) as spi:
spi.mode = 0 spi.mode = 0
spi.no_cs = (not self.__hw_cs) spi.no_cs = (not self.__hw_cs)