diff options
Diffstat (limited to 'pkg/hocr')
-rw-r--r-- | pkg/hocr/lines.go | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/pkg/hocr/lines.go b/pkg/hocr/lines.go index d2983be..3e4dc65 100644 --- a/pkg/hocr/lines.go +++ b/pkg/hocr/lines.go @@ -9,7 +9,6 @@ import ( _ "image/jpeg" _ "image/png" "io/ioutil" - "log" "os" "path/filepath" "strings" @@ -85,6 +84,8 @@ func parseLineDetails(h Hocr, i *image.Gray, name string) (line.Details, error) return lines, nil } +// GetLineDetails parses a hocr file and returns a corresponding +// line.Details, including image extracts for each line. func GetLineDetails(hocrfn string) (line.Details, error) { var newlines line.Details @@ -102,14 +103,10 @@ func GetLineDetails(hocrfn string) (line.Details, error) { var gray *image.Gray pngfn := strings.Replace(hocrfn, ".hocr", ".png", 1) pngf, err := os.Open(pngfn) - if err != nil { - log.Println("Warning: can't open image %s\n", pngfn) - } else { + if err == nil { defer pngf.Close() img, _, err = image.Decode(pngf) - if err != nil { - log.Println("Warning: can't load image %s\n", pngfn) - } else { + if err == nil { b := img.Bounds() gray = image.NewGray(image.Rect(0, 0, b.Dx(), b.Dy())) draw.Draw(gray, b, img, b.Min, draw.Src) @@ -120,6 +117,8 @@ func GetLineDetails(hocrfn string) (line.Details, error) { return parseLineDetails(h, gray, n) } +// GetLineBasics parses a hocr file and returns a corresponding +// line.Details, without any image extracts. func GetLineBasics(hocrfn string) (line.Details, error) { var newlines line.Details |