當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。