gosseract

package
v0.0.0-...-aea0bbf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2018 License: MIT, MIT Imports: 9 Imported by: 0

README

Gosseract-OCR Build Status GoDoc

Tesseract-OCR command for Golang

Quick Start

If you have docker on your machine, just hit this and try with GUI

docker run -it --rm -e PORT=8080 -p 8080:8080 otiai10/ocrserver

Code Example

package main

import (
	"fmt"
	"github.com/otiai10/gosseract"
)

func main() {
    // This is the simplest way :)
    out := gosseract.Must(gosseract.Params{
			Src:       "your/img/file.png",
			Languages: "eng+heb",
    })
    fmt.Println(out)

    // Using client
    client, _ := gosseract.NewClient()
    out, _ = client.Src("your/img/file.png").Out()
    fmt.Println(out)
}

Server Application

Here it is a ready-made solution.

ocrserver ocrserver: the minimum OCR server with using gosseract.

Installation

  1. install tesseract-ocr
  2. install go
  3. install gosseract
    • go get github.com/otiai10/gosseract
  4. install mint for testing
    • go get github.com/otiai10/mint
  5. run the tests first↓

Test

go test ./...

Dependencies

Known Issues

Documentation

Index

Examples

Constants

View Source
const TESSERACT = "tesseract"

TESSERACT specifies bin name for tesseract.

Variables

This section is empty.

Functions

func Must

func Must(params Params) (out string)

Must execute tesseract-OCR directly by parameter map

Example
package main

import (
	"github.com/otiai10/gosseract/v1/gosseract"

	"fmt"
)

func main() {
	// TODO: it panics! error handling in *Client.accept
	out := gosseract.Must(gosseract.Params{Src: "./.samples/png/sample002.png", Languages: "eng+heb"})
	fmt.Println(out)
}
Output:

Types

type Client

type Client struct {
	Error error
	// contains filtered or unexported fields
}

Client is an client to use gosseract functions

func NewClient

func NewClient() (c *Client, e error)

NewClient provide reference to new Client

func (*Client) Digest

func (c *Client) Digest(digestPath string) *Client

Digest accepts path to target digest file

func (*Client) Image

func (c *Client) Image(img image.Image) *Client

Image accepts image object of target

Example
package main

import (
	"github.com/otiai10/gosseract/v1/gosseract"

	"fmt"
	"image"
)

func main() {
	client, _ := gosseract.NewClient()
	var img image.Image // any your image instance
	out, _ := client.Image(img).Out()
	fmt.Println(out)
}
Output:

func (*Client) Must

func (c *Client) Must(params map[string]string) (out string, e error)

Must executes tesseract directly by parameter map

func (*Client) Out

func (c *Client) Out() (out string, e error)

Out executes tesseract and gives results

func (*Client) Src

func (c *Client) Src(srcPath string) *Client

Src accepts path to target source file

Example
package main

import (
	"github.com/otiai10/gosseract/v1/gosseract"

	"fmt"
)

func main() {
	client, _ := gosseract.NewClient()
	out, _ := client.Src("./samples/png/samples000.png").Out()
	fmt.Println(out)
}
Output:

type Params

type Params struct {
	Src       string // source image file path
	Whitelist string // tessedit_char_whitelist
	Languages string
}

Params is parameters for gosseract.Must.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL