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

NotFoundException using MultiFormatUPCEANReader #68

Open
lnds opened this issue May 31, 2024 · 1 comment
Open

NotFoundException using MultiFormatUPCEANReader #68

lnds opened this issue May 31, 2024 · 1 comment

Comments

@lnds
Copy link

lnds commented May 31, 2024

When trying to decode this image I get NotFoundException.

Here's my code:

func scanBarCode(fileName string) {
file,  _ := os.Open(fileName)
img, _,_ := image.Decode(file)
bmp, err := gozxing.NewBinaryBitmapFromImage(img)
if err != nil {
    fmt.Println("error: could not get bmp from image", err)
   return
}
reader := oned.NewMultiFormatUPCEANReader(nil)

result, err := reader.DecodeWithoutHints(bmp)
if err != nil {
   fmt.Println("error: no barcode found in image", err)
  return
}
fmt.Println("success:", result)
}

7

@makiuchi-d
Copy link
Owner

It seems that there is not enough white space on both sides.
I got the result by adding white space.

img, _,_ := image.Decode(file)

img2 := image.NewRGBA(image.Rect(0, 0, 3000, 2500))
draw.Draw(img2, img2.Bounds(), image.White, image.Pt(0, 0), draw.Over)
draw.Draw(img2, image.Rect(250, 0, 2750, 2500), img, image.Pt(0, 0), draw.Over)

bmp, err := gozxing.NewBinaryBitmapFromImage(img2)

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

2 participants