blob: 3ddde76228f8c3fcbf8798714951323860890834 (
plain)
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
|
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"
)
type LineDetail struct {
Name string
Avgconf float64
Img CopyableLine
Text string
Hocrname 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 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] }
|