summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/bookpipeline/main.go2
-rw-r--r--cmd/rescribe/main.go2
-rw-r--r--internal/pipeline/pipeline.go30
3 files changed, 18 insertions, 16 deletions
diff --git a/cmd/bookpipeline/main.go b/cmd/bookpipeline/main.go
index aff7b87..12d5eec 100644
--- a/cmd/bookpipeline/main.go
+++ b/cmd/bookpipeline/main.go
@@ -188,7 +188,7 @@ func main() {
}
conn.Log("Message received on preprocess queue, processing", msg.Body)
stopTimer(stopIfQuiet)
- err = pipeline.ProcessBook(msg, conn, pipeline.Preprocess, origPattern, conn.PreQueueId(), conn.OCRPageQueueId())
+ err = pipeline.ProcessBook(msg, conn, pipeline.Preprocess([]float64{0.1, 0.2, 0.4, 0.5}), origPattern, conn.PreQueueId(), conn.OCRPageQueueId())
resetTimer(stopIfQuiet, quietTime)
if err != nil {
conn.Log("Error during preprocess", err)
diff --git a/cmd/rescribe/main.go b/cmd/rescribe/main.go
index c309367..1a3dcff 100644
--- a/cmd/rescribe/main.go
+++ b/cmd/rescribe/main.go
@@ -221,7 +221,7 @@ func processbook(training string, conn Pipeliner) {
}
conn.Log("Message received on preprocess queue, processing", msg.Body)
stopTimer(stopIfQuiet)
- err = pipeline.ProcessBook(msg, conn, pipeline.Preprocess, origPattern, conn.PreQueueId(), conn.OCRPageQueueId())
+ err = pipeline.ProcessBook(msg, conn, pipeline.Preprocess([]float64{0.1, 0.2, 0.3}), origPattern, conn.PreQueueId(), conn.OCRPageQueueId())
resetTimer(stopIfQuiet, quietTime)
if err != nil {
conn.Log("Error during preprocess", err)
diff --git a/internal/pipeline/pipeline.go b/internal/pipeline/pipeline.go
index b1c3cb9..cce5c19 100644
--- a/internal/pipeline/pipeline.go
+++ b/internal/pipeline/pipeline.go
@@ -146,22 +146,24 @@ func upAndQueue(c chan string, done chan bool, toQueue string, conn Pipeliner, b
done <- true
}
-func Preprocess(pre chan string, up chan string, errc chan error, logger *log.Logger) {
- for path := range pre {
- logger.Println("Preprocessing", path)
- done, err := preproc.PreProcMulti(path, []float64{0.1, 0.2, 0.4, 0.5}, "binary", 0, true, 5, 30, 120, 30)
- if err != nil {
- for range pre {
- } // consume the rest of the receiving channel so it isn't blocked
- errc <- err
- return
- }
- _ = os.Remove(path)
- for _, p := range done {
- up <- p
+func Preprocess(thresholds []float64) func(chan string, chan string, chan error, *log.Logger) {
+ return func(pre chan string, up chan string, errc chan error, logger *log.Logger) {
+ for path := range pre {
+ logger.Println("Preprocessing", path)
+ done, err := preproc.PreProcMulti(path, thresholds, "binary", 0, true, 5, 30, 120, 30)
+ if err != nil {
+ for range pre {
+ } // consume the rest of the receiving channel so it isn't blocked
+ errc <- err
+ return
+ }
+ _ = os.Remove(path)
+ for _, p := range done {
+ up <- p
+ }
}
+ close(up)
}
- close(up)
}
func Wipe(towipe chan string, up chan string, errc chan error, logger *log.Logger) {