GithubHelp home page GithubHelp logo

otiai10 / ocrserver Goto Github PK

View Code? Open in Web Editor NEW
657.0 17.0 133.0 349 KB

A simple OCR API server, seriously easy to be deployed by Docker, on Heroku as well

Home Page: https://ocr-example.herokuapp.com/

License: MIT License

Go 52.49% JavaScript 15.81% HTML 26.45% CSS 2.39% Dockerfile 2.86%
go ocr ocr-server docker heroku api api-server curl

ocrserver's Introduction

ocrserver

Go CI codecov Go Report Card

Simple OCR server, as a small working sample for gosseract.

Try now here https://ocr-example.herokuapp.com/, and deploy your own now.

Deploy to Heroku

# Get the code
% git clone [email protected]:otiai10/ocrserver.git
% cd ocrserver
# Make your app
% heroku login
% heroku create
# Deploy the container
% heroku container:login
% heroku container:push web
# Enjoy it!
% heroku open

cf. heroku cli

Quick Start

Ready-Made Docker Image

% docker run -p 8080:8080 otiai10/ocrserver
# open http://localhost:8080

cf. docker

Development with Docker Image

% docker-compose up
# open http://localhost:8080

You need more languages?

% docker-compose build --build-arg LOAD_LANG=rus
% docker-compose up

cf. docker-compose

Manual Setup

If you have tesseract-ocr and library files on your machine

% go get github.com/otiai10/ocrserver/...
% PORT=8080 ocrserver
# open http://localhost:8080

cf. gosseract

Documents

ocrserver's People

Contributors

otiai10 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ocrserver's Issues

Setting language via http.request

Hi,

I think your project is great and I like the Docker solution very much. however, I just can't get it to change the language in the header at the moment.

Would you have a tip for me how I could change this?

I already tried with Header.Add and writer.CreateFormField("languages") without success.

Thanks a lot

`file, _ := os.Open(datei)
defer file.Close()

body := new(bytes.Buffer)
writer := multipart.NewWriter(body)
part2, err := writer.CreateFormField("languages")
part, _ := writer.CreateFormFile("file", filepath.Base(file.Name()))

if err != nil {
	fmt.Printf("Error creatformfield: %s", err)
}

part2.Write([]byte("deu"))
io.Copy(part, file)
writer.Close()

r, _ := http.NewRequest("POST", "http://10.6.0.3:9080/file", body)
//r.Header.Add("languages", "deu")
//r.Header.Set("languages", "deu")
r.Header.Add("Content-Type", writer.FormDataContentType())

stdlib.h: No such file or directory

I have a Ubuntu Server VM as I hate Docker, the machine is clean and created with the following commands:

#Install go
rm -r /temp &&
mkdir /temp &&
cd /temp &&
wget https://dl.google.com/go/go1.13.7.linux-amd64.tar.gz &&
tar -xvf go1.13.7.linux-amd64.tar.gz &&
mv go /usr/local &&
cd / &&
rm -r /temp &&
export GOROOT=/usr/local/go &&
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

#Install libs
#2 - Lib installation
apt-get install -y
tesseract-ocr-all
libtesseract-dev
imagemagick
libleptonica-dev
gcc

So when:
go get github.com/otiai10/ocrserver/...

The following error is thrown:
image

PD:

  1. Tesseract does work individually as I can use the command line to interact with it
  2. Go does work properly as I tested an hello world from git

fail to run main.go

Hello

i get the following error when running the code:

github.com/otiai10/gosseract/v2

cc1.exe: sorry, unimplemented: 64-bit mode not compiled in

#reprdocuceable every time

go env

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\BlackPearl\AppData\Local\go-build
set GOENV=C:\Users\BlackPearl\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\BlackPearl\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\BLACKP~1\AppData\Local\Temp\go-build118439850=/tmp/go-build -gno-record-gcc-switches

go version

go version go1.15.6 windows/amd64

tesseract --version

tesseract v4.0.0.20190314
leptonica-1.78.0
libgif 5.1.4 : libjpeg 8d (libjpeg-turbo 1.5.3) : libpng 1.6.34 : libtiff 4.0.9 : zlib 1.2.11 : libwebp 0.6.1 : libopenjp2 2.2.0
Found AVX2
Found AVX
Found SSE

New logo for OCRserver

I wanted to contribute to OCRserver I designed a logo for OCRserver. If you like it, I'll send you the all files.

1
2

CORS not working

I deployed this container to Heroku and sending POST requests via curl works great! However, I have trouble getting POST requests via a React web app due to CORS. What is the best way to enable CORS on this project, since it implements the request endpoints using marmoset? Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.