diff options
author | Nick White <git@njw.name> | 2019-01-25 09:55:55 +0000 |
---|---|---|
committer | Nick White <git@njw.name> | 2019-01-25 09:55:55 +0000 |
commit | 30c088b90e7b6a25d93cbdad7564ff063e62afd3 (patch) | |
tree | c47d7bc086a076cfe5e702628c4e5e3b1eab1aa5 /parse/line.go | |
parent | 1c17766952bdcd6f7d31d0fa1a2e504b1aa4f14a (diff) |
Reorganisation and cleanup
Diffstat (limited to 'parse/line.go')
-rw-r--r-- | parse/line.go | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/parse/line.go b/parse/line.go deleted file mode 100644 index 9a2be8e..0000000 --- a/parse/line.go +++ /dev/null @@ -1,67 +0,0 @@ -package parse - -// TODO: integrate in line-conf-buckets linedetail -// TODO: add BucketUp() function here that does what both line-conf-buckets-tess.go -// and line-conf-buckets.go do -// TODO: consider naming this package line, and separating it from hocr and prob - -import ( - "image" - "image/png" - "io" - "os" -) - -type LineDetail struct { - Name string - Avgconf float64 - Img CopyableLine - Text string - OcrName string -} - -type CopyableLine interface { - CopyLineTo(io.Writer) (error) -} - -// This is an implementation of the CopyableLine interface that -// stores the image directly as an image.Image -type ImgDirect struct { - Img image.Image -} - -func (i ImgDirect) CopyLineTo(w io.Writer) (error) { - err := png.Encode(w, i.Img) - if err != nil { - return err - } - return nil -} - -type ImgPath struct { - Path string -} - -func (i ImgPath) CopyLineTo(w io.Writer) (error) { - f, err := os.Open(i.Path) - if err != nil { - return err - } - defer f.Close() - - _, err = io.Copy(w, f) - return err -} - -type LineDetails []LineDetail - -// Used by sort.Sort. -func (l LineDetails) Len() int { return len(l) } - -// Used by sort.Sort. -func (l LineDetails) Less(i, j int) bool { - return l[i].Avgconf < l[j].Avgconf -} - -// Used by sort.Sort. -func (l LineDetails) Swap(i, j int) { l[i], l[j] = l[j], l[i] } |