#walkzzz/image.mbt/process/barcode

    条形码与二维码检测识别

    #概览

    项目数量
    公开函数15
    公开类型6
    常量0
    错误类型0

    #类型

    pub(all) struct BarcodeConfig {
    pub(all) struct BarcodeResult {
    pub(all) enum BarcodeType {
    pub(all) enum Code128Charset {
    pub(all) struct QrDecodeResult {
    pub(all) struct QrFinderPattern {

    #API

    pub fn barcode_default_config() -> BarcodeConfig
    pub fn decode_barcode(@types.Image, config? : BarcodeConfig) -> Array[BarcodeResult] raise @types.LoadError
    pub fn decode_code128(@types.Image) -> BarcodeResult? raise @types.LoadError
    pub fn decode_code39(@types.Image) -> BarcodeResult? raise @types.LoadError
    pub fn decode_ean13(@types.Image, config? : BarcodeConfig) -> BarcodeResult? raise @types.LoadError
    pub fn decode_linear_barcode(@types.Image) -> Array[BarcodeResult] raise @types.LoadError
    pub fn decode_qrcode(@types.Image, config? : BarcodeConfig) -> BarcodeResult? raise @types.LoadError
    pub fn decode_qrcode_full(@types.Image) -> QrDecodeResult? raise @types.LoadError
    pub fn decode_upca(@types.Image) -> BarcodeResult? raise @types.LoadError
    pub fn detect_qr_finder_patterns(@types.Image) -> Array[QrFinderPattern] raise @types.LoadError
    pub fn reed_solomon_decode(Array[Int], Int) -> (Array[Int], Int)
    pub fn BarcodeType::equal(Self, Self) -> Bool
    pub fn BarcodeType::not_equal(Self, Self) -> Bool
    pub fn Code128Charset::equal(Self, Self) -> Bool
    pub fn Code128Charset::not_equal(Self, Self) -> Bool

    #纯 MoonBit 实现

    本包不依赖任何 C FFI,四目标(native/wasm-gc/js/wasm)均可编译运行。

    BarcodeConfig

    pub(all) struct BarcodeConfig {
    enable_ean13 : Bool
    enable_upca : Bool
    enable_code128 : Bool
    enable_qrcode : Bool
    min_bar_width : Int
    max_bar_width : Int
    scan_lines : Int
    quiet_zone_required : Bool
    } derive(Default, Eq,
    Debug
    )

    条形码识别配置

    BarcodeConfig::default

    fn BarcodeConfig::default() -> BarcodeConfig
    automatically derived

    BarcodeConfig::equal

    automatically derived

    BarcodeConfig::not_equal

    fn BarcodeConfig::not_equal(x : BarcodeConfig, y : BarcodeConfig) -> Bool
    automatically derived

    BarcodeConfig::to_repr

    automatically derived

    BarcodeResult

    pub(all) struct BarcodeResult {
    barcode_type : BarcodeType
    data : String
    confidence : Double
    x : Int
    y : Int
    width : Int
    height : Int
    } derive(Eq,
    Debug
    )

    条形码识别结果

    BarcodeResult::equal

    automatically derived

    BarcodeResult::not_equal

    fn BarcodeResult::not_equal(x : BarcodeResult, y : BarcodeResult) -> Bool
    automatically derived

    BarcodeResult::to_repr

    automatically derived

    BarcodeType

    pub(all) enum BarcodeType {
    Ean13
    UpcA
    Code128
    QrCode
    Unknown
    } derive(Eq,
    Debug
    )

    条形码类型 #non_exhaustive 表示未来可能添加新构造器

    BarcodeType::equal

    fn BarcodeType::equal(BarcodeType, BarcodeType) -> Bool
    automatically derived

    BarcodeType::not_equal

    fn BarcodeType::not_equal(x : BarcodeType, y : BarcodeType) -> Bool
    automatically derived

    BarcodeType::to_repr

    automatically derived

    Code128Charset

    pub(all) enum Code128Charset {
    CodeA
    CodeB
    CodeC
    } derive(Eq,
    Debug
    )

    Code128 字符集类型

    Code128Charset::equal

    automatically derived

    Code128Charset::not_equal

    fn Code128Charset::not_equal(x : Code128Charset, y : Code128Charset) -> Bool
    automatically derived

    Code128Charset::to_repr

    automatically derived

    QrDecodeResult

    pub(all) struct QrDecodeResult {
    data : String
    version : Int
    error_correction_level : String
    mask_pattern : Int
    confidence : Double
    corrected_errors : Int
    } derive(Default, Eq,
    Debug
    )

    QR Code 解码结果

    QrDecodeResult::default

    automatically derived

    QrDecodeResult::equal

    automatically derived

    QrDecodeResult::not_equal

    fn QrDecodeResult::not_equal(x : QrDecodeResult, y : QrDecodeResult) -> Bool
    automatically derived

    QrDecodeResult::to_repr

    automatically derived

    QrFinderPattern

    pub(all) struct QrFinderPattern {
    x : Double
    y : Double
    size : Double
    quality : Double
    } derive(Default, Eq,
    Debug
    )

    QR Code 定位图案(Finder Pattern)

    QrFinderPattern::default

    automatically derived

    QrFinderPattern::equal

    automatically derived

    QrFinderPattern::not_equal

    fn QrFinderPattern::not_equal(x : QrFinderPattern, y : QrFinderPattern) -> Bool
    automatically derived

    QrFinderPattern::to_repr

    automatically derived

    barcode_default_config

    fn barcode_default_config() -> BarcodeConfig

    创建默认条形码识别配置

    decode_barcode

    fn decode_barcode(img :
    core
    /types.Image, config? : BarcodeConfig) -> Array[BarcodeResult] raise
    core
    /types.LoadError

    通用条形码识别(自动尝试所有启用的类型)

    decode_code128

    fn decode_code128(img :
    core
    /types.Image) -> BarcodeResult? raise
    core
    /types.LoadError

    识别 Code128 条形码

    decode_code39

    fn decode_code39(img :
    core
    /types.Image) -> BarcodeResult? raise
    core
    /types.LoadError

    识别 Code39 条形码

    decode_ean13

    fn decode_ean13(img :
    core
    /types.Image, config? : BarcodeConfig) -> BarcodeResult? raise
    core
    /types.LoadError

    识别 EAN-13 条形码

    decode_linear_barcode

    fn decode_linear_barcode(img :
    core
    /types.Image) -> Array[BarcodeResult] raise
    core
    /types.LoadError

    通用一维码识别(自动尝试所有类型)

    decode_qrcode

    fn decode_qrcode(img :
    core
    /types.Image, config? : BarcodeConfig) -> BarcodeResult? raise
    core
    /types.LoadError

    识别 QR Code(基础版:检测定位图案并估算版本)

    decode_qrcode_full

    fn decode_qrcode_full(img :
    core
    /types.Image) -> QrDecodeResult? raise
    core
    /types.LoadError

    解码 QR Code(完整版本)

    decode_upca

    fn decode_upca(img :
    core
    /types.Image) -> BarcodeResult? raise
    core
    /types.LoadError

    识别 UPC-A 条形码

    detect_qr_finder_patterns

    fn detect_qr_finder_patterns(img :
    core
    /types.Image) -> Array[QrFinderPattern] raise
    core
    /types.LoadError

    检测 QR Code 定位图案

    reed_solomon_decode

    fn reed_solomon_decode(data : Array[Int], ec_bytes : Int) -> (Array[Int], Int)

    Reed-Solomon 纠错(简化版 GF(256))