Closed Kanna-Neko closed 1 year ago
Your image is slightly distorted, so it's not being read properly.
I heavily distorted the image to make it readable. It would be better to prepare a more properly aligned image.
import (
"golang.org/x/image/draw"
"golang.org/x/image/math/f64"
)
...
w, h := img.Bounds().Max.X, img.Bounds().Max.Y
aff := f64.Aff3{0.8*0.5, -0.866, float64(w), 0.866, 1.5*0.5, 0}
img2 := image.NewRGBA(image.Rect(0, 0, w*2, h*2))
draw.NearestNeighbor.Transform(img2, aff, img, img.Bounds(), draw.Over, nil)
// prepare BinaryBitmap
bmp, _ := gozxing.NewBinaryBitmapFromImage(img2)
The result:
{"data":{"goods":[{"number":1,"barcode":"9787113266622"},{"number":2,"barcode":"6939261901617"}],"openid":"oPOop5BprabtLarGEuyefvGrIcnI"}}
Thank you very much for solving my problem.
this is my code, the error occur in the last row:
The qrcode is