forked from otiai10/gosseract
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_test.go
56 lines (40 loc) · 971 Bytes
/
example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package gosseract
import (
"fmt"
"os"
)
func ExampleNewClient() {
client := NewClient()
// Never forget to defer Close. It is due to caller to Close this client.
defer client.Close()
}
func ExampleClient_SetImage() {
client := NewClient()
defer client.Close()
client.SetImage("./test/data/001-helloworld.png")
// See "ExampleClient_Text" for more practical usecase ;)
}
func ExampleClient_Text() {
client := NewClient()
defer client.Close()
client.SetImage("./test/data/001-helloworld.png")
text, err := client.Text()
fmt.Println(text, err)
// OUTPUT:
// Hello, World! <nil>
}
func ExampleClient_SetWhitelist() {
if os.Getenv("TESS_LSTM_DISABLED") == "1" {
os.Exit(0)
}
client := NewClient()
defer client.Close()
client.SetImage("./test/data/002-confusing.png")
client.SetWhitelist("IO-")
text1, _ := client.Text()
client.SetWhitelist("10-")
text2, _ := client.Text()
fmt.Println(text1, text2)
// OUTPUT:
// IO- IOO 10-100
}