| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- -- qrcode.lua
- local qrcode = {}
- qrcode.__index = qrcode
- --[[
- 创建一个新的 fw_qrcode 对象
- @param obj 可选,已有的 fw_qrcode 对象
- @return 返回一个新的 qrcode 包装对象
- ]]
- function qrcode.new(obj)
- local instance = setmetatable({}, qrcode)
- if obj == nil then
- instance.module = fw_qrcode.new()
- else
- instance.module = obj
- end
- return instance
- end
- --[[
- 从原始像素解码二维码
- @param width 图像宽度
- @param height 图像高度
- @param pixels 像素二进制,灰度/RGB/RGBA
- @param channels 通道数,1/3/4,默认 1
- @return 识别结果数组,每项包含 ok、payload、corners 等字段
- ]]
- function qrcode:decode(width, height, pixels, channels)
- return self.module:decode(width, height, pixels, channels)
- end
- --[[
- 从 JPEG/PNG/BMP/GIF 图像二进制解码二维码
- @param data 图像文件内容
- @return 识别结果数组
- ]]
- function qrcode:decode_image(data)
- return self.module:decode_image(data)
- end
- --[[
- 从图像文件解码二维码
- @param path 文件路径
- @return 识别结果数组
- ]]
- function qrcode:decode_file(path)
- return self.module:decode_file(path)
- end
- function qrcode:self()
- return self.module:self()
- end
- function qrcode:last_error()
- return self.module:last_error()
- end
- function qrcode:version()
- return self.module:version()
- end
- return qrcode
|