Skip to content

Commit

Permalink
Misc HTML doc changes
Browse files Browse the repository at this point in the history
List of changes:
- Use common source URL
- Set readme as default HTML doc page
- Clean up and rewrite README
- Fix code examples wrong indentation
- Badges and more badges!
  • Loading branch information
kianmeng committed Oct 17, 2020
1 parent fc32055 commit f29ab58
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 41 deletions.
45 changes: 23 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
# TesseractOcr

[![Build Status](https://api.travis-ci.org/dannnylo/tesseract-ocr-elixir.svg)](https://travis-ci.org/dannnylo/tesseract-ocr-elixir)
[![travis-ci.org](https://api.travis-ci.org/dannnylo/tesseract-ocr-elixir.svg)](https://travis-ci.org/dannnylo/tesseract-ocr-elixir)
[![hex.pm](https://img.shields.io/hexpm/v/tesseract_ocr.svg)](https://hex.pm/packages/tesseract_ocr)
[![hex.pm](https://img.shields.io/badge/docs-hexpm-blue.svg)](https://hexdocs.pm/tesseract_ocr)
[![hex.pm](https://img.shields.io/hexpm/dt/tesseract_ocr.svg)](https://hex.pm/packages/tesseract_ocr)
[![hex.pm](https://img.shields.io/hexpm/l/tesseract_ocr.svg)](https://hex.pm/packages/tesseract_ocr)
[![github.com](https://img.shields.io/github/last-commit/dannnylo/tesseract-ocr-elixir.svg)](https://github.com/dannnylo/tesseract-ocr-elixir/commits/master)

This package is a wrapper of Tesseract OCR. Helping to read characters on a image.
Elixir wrapper for [Tesseract OCR](https://github.com/tesseract-ocr), an open
source text recognition (OCR) Engine.

## Requirements

- Elixir 1.6+ / Erlang OTP 19+
- [Tesseract OCR binary](https://github.com/tesseract-ocr/tesseract/wiki)

## Installation

If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `tesseract_ocr` to your list of dependencies in `mix.exs`:
The package can be installed by adding `tesseract_ocr` to your list of
dependencies in `mix.exs`:

```elixir
def deps do
Expand All @@ -17,35 +28,25 @@ def deps do
end
```

*** Atention: You will need to install the tesseract Ocr application on your operation system. ***
[Instalation wiki](https://github.com/tesseract-ocr/tesseract/wiki)

## Usage
Basic usage:

```elixir
TesseractOCR.read('path/of/my/image.ext')
```
Reading an image file.

```elixir
iex> TesseractOcr.read("test/resources/world.png")
"world"
iex> TesseractOcr.read("test/resources/world.png")
"world"
```

With options:
With additional options.

```elixir
iex> TesseractOcr.read("test/resources/world.png", %{lang: 'por', psm: 7, oem: 1})
"world"
iex> TesseractOcr.read("test/resources/world.png", %{lang: 'por', psm: 7, oem: 1})
"world"
```

Get words positions:
Get words positions.

```elixir
iex> TesseractOcr.Words.read("test/resources/world.png")
[%{confidence: 95, word: "world", x_end: 185, x_start: 2, y_end: 56, y_start: 2}]
[%{confidence: 95, word: "world", x_end: 185, x_start: 2, y_end: 56, y_start: 2}]
```

Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/tesseract_ocr](https://hexdocs.pm/tesseract_ocr).
3 changes: 1 addition & 2 deletions lib/tesseract_ocr.ex
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
defmodule TesseractOcr do
@moduledoc """
Documentation for TesseractOcr.
This Module is a wrapper of tesseract-ocr
"""

import TesseractOcr.Utils

@doc """
This function reads the chars on image by OCR
This function reads the chars on image by OCR.
## Examples
Expand Down
18 changes: 9 additions & 9 deletions lib/tesseract_ocr/utils.ex
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
defmodule TesseractOcr.Utils do
@moduledoc """
Utilities to run tesseract-ocr
Utilities to run `tesseract-ocr` binary.
"""

@doc """
This function executes the tesseract on system and return the output
This function executes the tesseract on system and return the output.
"""
def command(path, output, options) do
System.cmd("tesseract", command_options(path, output, options))
end

@doc """
This function will mount the options to tesseract OCR
This function will mount the options to Tesseract OCR.
## Examples
iex> TesseractOcr.Utils.command_options("test/resources/world.png", "stdout", %{l: "por", oem: "1"})
["test/resources/world.png", "stdout", "-l", "por", "--oem","1"]
iex> TesseractOcr.Utils.command_options("test/resources/world.png", "stdout", %{l: "por", oem: "1"})
["test/resources/world.png", "stdout", "-l", "por", "--oem","1"]
iex> TesseractOcr.Utils.command_options("test/resources/world.png", "stdout", %{l: "por", psm: 1})
["test/resources/world.png", "stdout", "-l", "por", "--psm", "1"]
iex> TesseractOcr.Utils.command_options("test/resources/world.png", "stdout", %{l: "por", psm: 1})
["test/resources/world.png", "stdout", "-l", "por", "--psm", "1"]
iex> TesseractOcr.Utils.command_options("test/resources/world.png", "stdout", %{c: "var=b"})
["test/resources/world.png", "stdout", "-c", "var=b"]
iex> TesseractOcr.Utils.command_options("test/resources/world.png", "stdout", %{c: "var=b"})
["test/resources/world.png", "stdout", "-c", "var=b"]
"""
def command_options(path, output, options) do
Expand Down
3 changes: 1 addition & 2 deletions lib/tesseract_ocr/words.ex
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
defmodule TesseractOcr.Words do
@moduledoc """
Documentation for TesseractOcrWords.
This Module is a wrapper of tesseract-ocr box
"""

import TesseractOcr.Utils

@doc """
This function reads the words on image by OCR and returns with positions
This function reads the words on image by OCR and returns with positions.
## Examples
Expand Down
28 changes: 22 additions & 6 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
defmodule TesseractOcr.MixProject do
use Mix.Project

@source_url "https://github.com/dannnylo/tesseract-ocr-elixir"

def project do
[
app: :tesseract_ocr,
version: "0.1.3",
elixir: "~> 1.6",
description: "A wrapper for Tesseract OCR",
description: description(),
start_permanent: Mix.env() == :prod,
test_coverage: [tool: ExCoveralls],
deps: deps(),
package: package(),
source_url: "https://github.com/dannnylo/tesseract-ocr-elixir"
docs: docs(),
test_coverage: [tool: ExCoveralls]
]
end

# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger]
]
end

# Run "mix help deps" to learn about dependencies.
defp description do
"""
Elixir wrapper for Tesseract OCR, an open source text recognition engine.
"""
end

defp deps do
[
{:secure_random, ">= 0.0.0"},
Expand All @@ -36,7 +42,17 @@ defmodule TesseractOcr.MixProject do
[
maintainers: ["Danilo Jeremias da Silva"],
licenses: ["MIT"],
links: %{"GitHub" => "https://github.com/dannnylo/tesseract-ocr-elixir"}
links: %{"GitHub" => @source_url}
]
end

defp docs do
[
main: "readme",
source_url: @source_url,
extras: [
"README.md"
]
]
end
end

0 comments on commit f29ab58

Please sign in to comment.