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

support jpeg? #28

Closed
halfcrazy opened this issue Aug 30, 2014 · 4 comments
Closed

support jpeg? #28

halfcrazy opened this issue Aug 30, 2014 · 4 comments
Assignees

Comments

@halfcrazy
Copy link

when i use the following code to ocr a jpeg format pic.

img_url := "http://cityjw.dlut.edu.cn:7001/ACTIONVALIDATERANDOMPICTURE.APPPROCESS"
resp, err := client.Get(img_url)
if err != nil {
// handle error
}
defer resp.Body.Close()
OcrClient, _ := gosseract.NewClient()
img, _ := jpeg.Decode(resp.Body)
out, _ := OcrClient.Image(img).Out()
fmt.Println(out)

and then i got some error.

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x43926a]

goroutine 1 [running]:
runtime.panic(0x664a20, 0x965b48)
/usr/lib/go/src/pkg/runtime/panic.c:266 +0xb6
github.com/otiai10/gosseract.(*Client).Image(0x0, 0x7f008865e7a0, 0xc210059480, 0x0)
/home/halfcrazy/gocode/src/github.com/otiai10/gosseract/client.go:58 +0x13a
main.main()
/home/halfcrazy/gocode/src/school_helper/main.go:29 +0x204

@otiai10 otiai10 self-assigned this Aug 31, 2014
@otiai10
Copy link
Owner

otiai10 commented Sep 1, 2014

@halfcrazy
Thanks to comment.
At first, this code works well in my environment.
#29

Anyway, through inspecting the reason why your code doesn't work, I found the file-extension I can get from that URL is ".appprocess".

I guess your decoding returns some error and img is pointing to nil.

img, _ := jpeg.Decode(resp.Body)

Please check it out

@JayXon
Copy link
Contributor

JayXon commented Sep 11, 2014

I just got the same panic from client.go:58.
But it turns out the reason was I don't have tesseract in my PATH.
Maybe you should make gosseract to print an error if tesseract is not in PATH.

@otiai10
Copy link
Owner

otiai10 commented Sep 12, 2014

@JayXon
Oh! Thank you very much!!
I'll impl it

@halfcrazy
Copy link
Author

@JayXon @otiai10 THX

@otiai10 otiai10 closed this as completed Oct 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants