-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
53 lines (44 loc) · 1.02 KB
/
main.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
package main
import (
"fmt"
"log"
"time"
"github.com/otiai10/gosseract/v2"
)
func main() {
iterations := 50
total := time.Duration(0)
fileName := "files/bode.jpg"
bytesImage := convertToBytes(fileName)
tm := TextMethod{
Name: "tesseract",
Language: "por",
Variables: map[string]string{
"tessedit_pageseg_mode": "3", // auto page segmentation mode
"load_system_dawg": "0", // removing dict to increase recognition
"load_freq_dawg": "0",
},
Client: nil,
}
instance = gosseract.NewClient()
defer instance.Close()
tm.Client = instance
tm.tesseractSettings()
for i := 0; i < iterations; i++ {
start := time.Now()
// Handler tesseract's settings
object, err := tm.extract(bytesImage)
if err != nil {
return
}
if object != nil {
fmt.Println(*object)
}
elapsed := time.Since(start)
log.Printf("took %s", elapsed)
total += elapsed
}
log.Printf("All Duration: %s", total)
log.Printf("loops: %d", iterations)
log.Printf("Average: %s", total/time.Duration(iterations))
}