summaryrefslogtreecommitdiff
path: root/bucket-lines
diff options
context:
space:
mode:
authorNick White <git@njw.name>2019-01-24 18:13:35 +0000
committerNick White <git@njw.name>2019-01-24 18:13:35 +0000
commit0efed080dec35be85bd8f0388a062c79c5ac544a (patch)
treeed6abe3ac729963a4e09bc573d80013f6ab03839 /bucket-lines
parent6e08494a8883a8e304ef02ea352a11776ab2294c (diff)
Better separation between library and tool
Diffstat (limited to 'bucket-lines')
-rw-r--r--bucket-lines/bucket-lines.go39
1 files changed, 3 insertions, 36 deletions
diff --git a/bucket-lines/bucket-lines.go b/bucket-lines/bucket-lines.go
index ad73fcd..186f568 100644
--- a/bucket-lines/bucket-lines.go
+++ b/bucket-lines/bucket-lines.go
@@ -3,51 +3,18 @@ package main
import (
"flag"
"fmt"
- "image/png"
- "io/ioutil"
"log"
"os"
"path/filepath"
- "strings"
"git.rescribe.xyz/testingtools/parse"
"git.rescribe.xyz/testingtools/parse/hocr"
"git.rescribe.xyz/testingtools/parse/prob"
)
-// TODO: maybe move this into hocr.go
-func detailsFromHocr(f string) (parse.LineDetails, error) {
- var newlines parse.LineDetails
-
- file, err := ioutil.ReadFile(f)
- if err != nil {
- return newlines, err
- }
-
- h, err := hocr.Parse(file)
- if err != nil {
- return newlines, err
- }
-
- pngfn := strings.Replace(f, ".hocr", ".png", 1)
- pngf, err := os.Open(pngfn)
- if err != nil {
- return newlines, err
- }
- defer pngf.Close()
- img, err := png.Decode(pngf)
- if err != nil {
- return newlines, err
- }
-
- n := strings.Replace(filepath.Base(f), ".hocr", "", 1)
- return hocr.GetLineDetails(h, img, n)
-}
-
func main() {
- // TODO: Allow different specs to be used for .prob vs .hocr. Do this
- // by adding a field to LineDetails that is linked to a named
- // BucketSpecs.
+ // TODO: Allow bucket specs to be determined by a json file passed
+ // as an argument.
b := parse.BucketSpecs{
// minimum confidence, name
{ 0, "bad" },
@@ -83,7 +50,7 @@ func main() {
case ".prob":
newlines, err = prob.GetLineDetails(f)
case ".hocr":
- newlines, err = detailsFromHocr(f)
+ newlines, err = hocr.GetLineDetails(f)
default:
log.Printf("Skipping file '%s' as it isn't a .prob or .hocr\n", f)
}