GithubHelp home page GithubHelp logo

How to parse QR code? about gs1qr HOT 2 CLOSED

knieriem avatar knieriem commented on July 16, 2024
How to parse QR code?

from gs1qr.

Comments (2)

knieriem avatar knieriem commented on July 16, 2024

It would possibly work using https://github.com/makiuchi-d/gozxing for scanning an image, decoding the QR code, like this:

bmp, _ := gozxing.NewBinaryBitmapFromImage(img)

qrReader := qrcode.NewQRCodeReader()
result, _ := qrReader.Decode(bmp, nil)

When decoding a QR code that was created using the example data, the code sequence

b := result.GetRawBytes()
fmt.Printf("raw: % x\n", b)

text := result.GetText()
fmt.Printf("text: %q\n", text)

will produce the following output:

raw: 51 05 00 a5 65 38 00 00 12 d8 02 07 b4 3a 3a 38 1d 17 97 b0 b1 31 97 37 32 ba 0e 90 18 16 de fc 9a 20 83 35 db 0d c3 30 b6 e0 ec 11

text: "01034531200000118200http://abc.net\x1d10XYZ\x1d4109501101020917"

Splitting the text string at the correct positions, the original data can be extracted:

[{01 03453120000011} {8200 http://abc.net} {10 XYZ} {410 9501101020917}]

With a bit of work, it should be possible to write a decoder that returns an []ai.Elem slice.

from gs1qr.

zhaixing724 avatar zhaixing724 commented on July 16, 2024

With a bit of work, it should be possible to write a decoder that returns an []ai.Elem slice.

It works great, thank you so much!

from gs1qr.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.