Read binary QR Code with AVFoundation

前端 未结 3 1089
鱼传尺愫
鱼传尺愫 2020-12-10 03:05

Is it possible to read a binary encoded QR code with AVFoundation?

I can get a AVMetadataMachineReadableCodeObject object of .type AV

3条回答
  •  猫巷女王i
    2020-12-10 03:20

    I was able to solve this issue by Base64 encoding the data in the QR code. This obviously won't work if you're not also generating the QR codes but could be option for people that are.

    We were running into the upper limit of data that can be stored in a QR code but by compressing the data (we used zlib) and then Base64 encoding the compressed data, so long as your data compresses to less than 75% of its original size you get some additional capacity and can use the stringValue property to get your data back out, you just have to Base64 decode and then decompress to get the original data back.

    Even if you're starting with binary data that isn't very compressible, so long as you can handle the overhead of Base64 and still be within the limitations of QR codes this may be a viable option that avoids working around the fact that AVMetadataMachineReadableCodeObject seems to want to work with string values.

提交回复
热议问题