Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_init(self):
"""Test Init calls with different lang and oem."""
self._api.Init(lang='eng+osd')
self.assertEqual(self._api.GetInitLanguagesAsString(), 'eng+osd')
self._api.Init(lang='eng')
self.assertEqual(self._api.GetInitLanguagesAsString(), 'eng')
self._api.Init(oem=tesserocr.OEM.TESSERACT_ONLY)
self.assertEqual(self._api.oem(), tesserocr.OEM.TESSERACT_ONLY)
def test_init(self):
"""Test Init calls with different lang and oem."""
self._api.Init(lang='eng+osd')
self.assertEqual(self._api.GetInitLanguagesAsString(), 'eng+osd')
self._api.Init(lang='eng')
self.assertEqual(self._api.GetInitLanguagesAsString(), 'eng')
self._api.Init(oem=tesserocr.OEM.TESSERACT_ONLY)
self.assertEqual(self._api.oem(), tesserocr.OEM.TESSERACT_ONLY)
black_pixel_count = image[image == 0].size
white_pixel_count = image[image == 1].size
if black_pixel_count > white_pixel_count:
image = skimage.util.invert(image)
image = skimage.morphology.closing(image, skimage.morphology.rectangle(1, horizontal_closing))
image = skimage.morphology.closing(image, skimage.morphology.rectangle(vertical_closing, 1))
image = skimage.util.img_as_ubyte(image)
if is_unix():
return tesserocr.image_to_text(
Image.fromarray(image),
psm=tesserocr.PSM.SINGLE_LINE,
oem=tesserocr.OEM.TESSERACT_ONLY
).strip()
elif is_windows():
return pytesseract.image_to_string(Image.fromarray(image))