当前位置: 首页>>代码示例>>Python>>正文


Python tesserocr.PyTessBaseAPI方法代码示例

本文整理汇总了Python中tesserocr.PyTessBaseAPI方法的典型用法代码示例。如果您正苦于以下问题:Python tesserocr.PyTessBaseAPI方法的具体用法?Python tesserocr.PyTessBaseAPI怎么用?Python tesserocr.PyTessBaseAPI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tesserocr的用法示例。


在下文中一共展示了tesserocr.PyTessBaseAPI方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: import tesserocr [as 别名]
# 或者: from tesserocr import PyTessBaseAPI [as 别名]
def setUp(self):
        if pil_installed:
            with open(self._image_file, 'rb') as f:
                self._image = Image.open(f)
                self._image.load()
        self._api = tesserocr.PyTessBaseAPI(init=True) 
开发者ID:sirfz,项目名称:tesserocr,代码行数:8,代码来源:test_api.py

示例2: image_ocr

# 需要导入模块: import tesserocr [as 别名]
# 或者: from tesserocr import PyTessBaseAPI [as 别名]
def image_ocr(path, lang):
  logger.info("opening %s", path)

  with PyTessBaseAPI() as api:
    api.SetImageFile(path)
    text = api.GetUTF8Text().strip()

  return text 
开发者ID:charslab,项目名称:TranscriberBot,代码行数:10,代码来源:ocr.py

示例3: post

# 需要导入模块: import tesserocr [as 别名]
# 或者: from tesserocr import PyTessBaseAPI [as 别名]
def post(self, request, *args, **kwargs):
        with PyTessBaseAPI() as api:
            with Image.open(request.FILES['image']) as image:
                sharpened_image = image.filter(ImageFilter.SHARPEN)
                api.SetImage(sharpened_image)
                utf8_text = api.GetUTF8Text()

        return JsonResponse({'utf8_text': utf8_text}) 
开发者ID:abarto,项目名称:ocr-with-django,代码行数:10,代码来源:views.py

示例4: get_api

# 需要导入模块: import tesserocr [as 别名]
# 或者: from tesserocr import PyTessBaseAPI [as 别名]
def get_api(self, languages):
        if not hasattr(self.thread, 'api'):
            from tesserocr import PyTessBaseAPI, PSM
            api = PyTessBaseAPI(lang=languages)
            api.SetPageSegMode(PSM.AUTO_OSD)
            self.thread.api = api
        return self.thread.api 
开发者ID:occrp-attic,项目名称:ingestors,代码行数:9,代码来源:ocr.py

示例5: get_ocr

# 需要导入模块: import tesserocr [as 别名]
# 或者: from tesserocr import PyTessBaseAPI [as 别名]
def get_ocr():
    """Check if OCR service is available; else throw an error"""
    if not hasattr(settings, '_ocr'):
        try:
            from tesserocr import PyTessBaseAPI, PSM, OEM
            log.info("Configuring OCR engine...")
            settings._ocr = PyTessBaseAPI(lang=LANGUAGES,
                                          oem=OEM.LSTM_ONLY,
                                          psm=PSM.AUTO_OSD)
        except ImportError:
            log.warning("OCR engine is not available")
            settings._ocr = None
    return settings._ocr 
开发者ID:alephdata,项目名称:memorious,代码行数:15,代码来源:ocr.py


注:本文中的tesserocr.PyTessBaseAPI方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。