• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

scott0123/Tesseract-macOS: Objective C wrapper for the open source OCR Engine Te ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

scott0123/Tesseract-macOS

开源软件地址(OpenSource Url):

https://github.com/scott0123/Tesseract-macOS

开源编程语言(OpenSource Language):

Objective-C 56.6%

开源软件介绍(OpenSource Introduction):

Tesseract macOS

Build Status license GitHub stars

This is an open-source macOS-based Objective-C wrapper for the OCR library Tesseract.

You can also use this in Swift, instructions below.

Fork this repo if you want to experiment with it.

Overview

The wrapper consists of just the following files

  • SLTesseract.h (Header file)
  • SLTesseract.mm (Implementation file)
  • tessdata/ (Language files for Tesseract)
  • lib/ (Compiled dependencies)
  • include/ (Headers for the dependencies)

Demo Application

For those of you who wish to first test out the OCR capabilities, the included Screenshot-OCR is a demo application to showcase this.

First build the Xcode project included in this repository. This will generate an application through wish you can take a screenshot, as shown in the following gif.

Screenshot example

In the Xcode log you will find the corresponding text Tesseract detected for this screenshot.

Output text

Getting Started

Getting this to work in your own project

  1. Clone this project

  2. Copy over the include, lib, and tessdata folders to your project.

  3. Add these folders to your project in Xcode. Make sure include and lib are added as groups and tessdata is added as a folder reference.

    The location of this setting is shown in the following image:

    add settings

  4. Copy over the files SLTesseract.mm and SLTesseract.h to your code directory.

  5. Verify that the file SLTesseract.mm is added to Targets > Build Phases > Compile Sources. Additionally, verify that all the static libraries are also added to Targets > Build Phases > Link Binary With Libraries. (This process should be done automatically)

  6. You are now ready to use Tesseract in your macOS project. (See Example Usage for code syntax)

Example Usage

At the top of the file include the header file

#import "SLTesseract.h"

And then

SLTesseract *ocr = [[SLTesseract alloc] init];

will initiallize the class SLTesseract.

(optional) ocr.language = @"eng";

(optional) ocr.charWhitelist = @"abcdefghijklmnopqrstuvwxyz"

(optional) ocr.charBlacklist = @"1234567890"

Finally, assuming you already have the image that you wish to perform OCR on in NSImage form, you can call

NSString *text = [ocr recognize:image];

to recognize the image in question and get the corresponding text.

Usage in Swift

This library can be easily imported in a Swift project.

Just replicate all the steps above.

When adding .h and .mm files you will be prompted by Xcode to add a Bridging Header (if don't have one already).

Xcode will generate a file named yourProject-Bridging-Header.h

Add this line to the Bridging Header:

#import "SLTesseract.h" 

Initialize like this:

let ocr = SLTesseract()

(optional) ocr.language = "eng"

(optional) ocr.charWhitelist = "abcdefghijklmnopqrstuvwxyz"

(optional) ocr.charBlacklist = "1234567890"

Finally perform OCR by doing this:

let text = ocr.recognize(image)

Dependencies

The libraries below are all included in the lib/ directory.

  • Tesseract (v4.1.1)
  • Leptonica (v1.8.0)
    • LibPNG (v1.6.37)
    • LibTIFF (v4.1.0)
    • LibJPEG (v9d)
    • LibZ (v1.2.11)
    • LibOpenJPEG (v2.3.1)
    • LibWebP (v1.1.0)
    • LibGIF (v5.2.1)

Additionally libcurl is required. To add libcurl, select your target in Xcode, select Build Phases tab and under Link Binary With Libraries phase click on the + button and type libcurl. Select libcurl.tbd.

License

My project Tesseract macOS itself is distributed under the MIT license (see LICENSE);

Keep in mind that the main dependency Tesseract is distributed under the Apache 2.0 license.

Contact

Open an issue if you want something fixed.

You may reach me at [email protected] to inquire about this project.

Used by




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
lmk123/oh-my-wechat: 微信小助手的安装 / 更新工具。发布时间:2022-08-18
下一篇:
tuxu/nbviewer-app: A Jupyter notebook viewer for macOS发布时间:2022-08-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap