Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PageSegMode will be Initialized to 6 after executing Client.Text() #167

Open
avan06 opened this issue Aug 11, 2019 · 3 comments
Open

PageSegMode will be Initialized to 6 after executing Client.Text() #167

avan06 opened this issue Aug 11, 2019 · 3 comments
Assignees
Labels

Comments

@avan06
Copy link

avan06 commented Aug 11, 2019

Summary

  • PageSegMode will be Initialized to 6 after executing Client.Text()

Reproducibility

Reproducibility Frequency

  • 100%

Reproducible

client := gosseract.NewClient()
client.SetLanguage("jpn_vert")
client.SetPageSegMode(gosseract.PSM_SINGLE_BLOCK_VERT_TEXT)	//set 5
fmt.Println(`PageSegMode1:`, client.GetPageSegMode())		//show 5
client.SetImageFromBytes(data)		//data is image of []byte
client.Text()	//This step will execute client.init() before outputting the OCR text.
fmt.Println(`PageSegMode2:`, client.GetPageSegMode())		//show 6
  • PS. I added GetPageSegMode() on
  • "github.com\otiai10\gosseract\client.go" for show PageSegMode
func (client *Client) GetPageSegMode() PageSegMode {
	return PageSegMode(C.GetPageSegMode(client.api))
}

Environment

Windows 10 using MSYS2 and Development by VSCODE
uname -a
MSYS_NT-10.0-16299 DESKTOP-QOD72I1 3.0.7-338.x86_64 2019-07-11 10:58 UTC x86_64 Msys
go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\avan\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=F:\cht\GOPATH
set GOPROXY=
set GORACE=
set GOROOT=F:\cht\go\go1.12.7
set GOTMPDIR=
set GOTOOLDIR=F:\cht\go\go1.12.7\pkg\tool\windows_amd64
set GCCGO=gccgo
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\avan\AppData\Local\Temp\go-build231297478=/tmp/go-build -gno-record-gcc-switches
go version
go version go1.12.7 windows/amd64
tesseract --version
tesseract 4.1.0
 leptonica-1.78.0
  libgif 5.1.8 : libjpeg 8d (libjpeg-turbo 2.0.2) : libpng 1.6.37 : libtiff 4.0.10 : zlib 1.2.11 : libwebp 1.0.3 : libopenjp2 2.3.1
 Found SSE
 Found libarchive 3.4.0 zlib/1.2.11 liblzma/5.2.4 bz2lib/1.0.8 liblz4/1.9.1 libzstd/1.4.0
@otiai10
Copy link
Owner

otiai10 commented Dec 17, 2019

@avan06 Could you give me a reproducible Docker?

@alanimgur
Copy link

I've been able to confirm this as well. It's causing me to SetPageSegMode before every Text call.

@otiai10 otiai10 self-assigned this Jan 20, 2021
@otiai10 otiai10 added the bug label Jan 20, 2021
@leftwichj
Copy link
Contributor

I just ran into this issue as well, for now to work around I'm just setting the variable name instead of using the SetPageMode
client.SetVariable("tessedit_pageseg_mode", "1")

In debugging the issue something in the client.init() is resetting the value to the default value of 6, once init() isn't called for subsequent images everything works smoothly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants