Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracting text is not working correctly in v5.3.0-2 in Alpine #293

Open
dongzhou77 opened this issue Sep 29, 2023 · 0 comments
Open

Extracting text is not working correctly in v5.3.0-2 in Alpine #293

dongzhou77 opened this issue Sep 29, 2023 · 0 comments

Comments

@dongzhou77
Copy link

dongzhou77 commented Sep 29, 2023

Summary

Hey, we are using gosseract library to extract text from certain png file but the output is not expected.
It was expected to extract "Jan3Fri2014" but the output is "Jan3Fr12014".

Reproducibility

Reproducibility Frequency

  • 100%

Test logic

package main

import (
	"strings"
	"testing"

	"github.com/otiai10/gosseract/v2"
)

func TestGenerateImage(t *testing.T) {

	var text = "Jan 3 Fri 2014"

	client := gosseract.NewClient()
	client.SetImage("./out.png")
	out, err := client.Text()
	if err != nil {
		t.Error(err)
	}
	if removeSpace(out) != removeSpace(text) {
		t.Errorf("expect: %s, got %s", removeSpace(text), removeSpace(out))
	}
	client.Close()
}

func removeSpace(s string) string {
	s = strings.TrimSpace(s)
	return strings.Join(strings.Split(s, " "), "")
}

Reproducible Dockerfile

FROM alpine:latest

RUN apk update
RUN apk add \
    g++ \
    git \
    musl-dev \
    go \
    tesseract-ocr-dev
RUN apk add tesseract-ocr-data-eng

ENV GOPATH=/root/go

ADD . ${GOPATH}/src/github.com/otiai10/gosseract
WORKDIR ${GOPATH}/src/github.com/otiai10/gosseract

ENV GOSSERACT_CPPSTDERR_NOT_CAPTURED=1
CMD ["go", "test", "-v", "./..."]

The png file has been attached.

out

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant