You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks Makiuchi-san. It works perfectly. I understand now the role of the hints. May I suggest that you provide an example using it in the documentation? This may help users. Following is a piece of code that uses your code with the hints.
// Decode attempts to extract the qrcode from `data`. `data` is expected to be a raw png// image. The function tries several strategies to decode in increasing order of processing time.funcDecode(data []byte) (string, error) {
img, err:=png.Decode(bytes.NewReader(data))
iferr!=nil {
return"", ErrNotPNG
}
// prepare BinaryBitmapbmp, err:=gozxing.NewBinaryBitmapFromImage(img)
iferr!=nil {
return"", ErrNotPNG
}
// decode imageqrReader:=qr1.NewQRCodeReader()
result, err:=qrReader.Decode(bmp, nil)
iferr==nil {
returnresult.GetText(), nil
}
m:=map[gozxing.DecodeHintType]any{
gozxing.DecodeHintType_PURE_BARCODE: true,
}
result, err=qrReader.Decode(bmp, m)
iferr==nil {
returnresult.GetText(), nil
}
m1:=map[gozxing.DecodeHintType]any{
gozxing.DecodeHintType_TRY_HARDER: true,
}
result, err=qrReader.Decode(bmp, m1)
iferr!=nil {
return"", ErrNotQRCode
}
returnresult.GetText(), nil
}
The attached PNG file cannot be detected by the lib. What am I doing wrong?
The text was updated successfully, but these errors were encountered: