ready for v1.0rc1
This commit is contained in:
parent
84d48a6eea
commit
ce5764840f
15 changed files with 140 additions and 49 deletions
|
|
@ -1,7 +0,0 @@
|
|||
// Copyright (C) 2019 Marius Schellenberger
|
||||
|
||||
// +build !openbsd
|
||||
|
||||
package scan
|
||||
|
||||
const tesseract_oem = "2"
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
// Copyright (C) 2019 Marius Schellenberger
|
||||
|
||||
// +build openbsd
|
||||
|
||||
package scan
|
||||
|
||||
const tesseract_oem = "1"
|
||||
|
|
@ -50,7 +50,7 @@ type Scanner struct {
|
|||
p PDF
|
||||
}
|
||||
|
||||
func New(base string, langs []string, threads int, timeout time.Duration) (s *Scanner, err error) {
|
||||
func New(c core.Config) (s *Scanner, err error) {
|
||||
var (
|
||||
tcmd string
|
||||
pcmd string
|
||||
|
|
@ -72,24 +72,27 @@ func New(base string, langs []string, threads int, timeout time.Duration) (s *Sc
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
if langs == nil {
|
||||
llen := len(c.Langs)
|
||||
langs := c.Langs
|
||||
if langs == nil || llen == 0 {
|
||||
langs = defaultLangs
|
||||
}
|
||||
for i, l := range langs {
|
||||
lang += l
|
||||
if i < len(langs)-1 {
|
||||
if i < llen-1 {
|
||||
lang += "+"
|
||||
}
|
||||
}
|
||||
threads := c.TesseractThreads
|
||||
if threads > maxThreads {
|
||||
threads = maxThreads
|
||||
} else if threads < minThreads {
|
||||
threads = minThreads
|
||||
}
|
||||
args := []string{"-l", lang, "--oem", tesseract_oem}
|
||||
args := []string{"-l", lang, "--oem", fmt.Sprintf("%d", c.TesseractOEM)}
|
||||
s = &Scanner{
|
||||
base,
|
||||
timeout,
|
||||
c.DataDir,
|
||||
time.Second * time.Duration(c.CMDTimeout),
|
||||
Tesseract{tcmd, args, []string{fmt.Sprintf("OMP_THREAD_LIMIT=%d", threads)}},
|
||||
PDF{pcmd, []string{"-layout", "-nopgbrk", "-eol", "unix"}},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue