mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-27 21:02:35 +00:00
change to using once_cell for lazy init
This commit is contained in:
@@ -15,7 +15,7 @@ exclude = [
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
regex = "1.7.0"
|
regex = "1.7.0"
|
||||||
fancy-regex = "0.10"
|
fancy-regex = "0.10"
|
||||||
lazy_static = "1.4.0"
|
once_cell = "1.17.0"
|
||||||
encoding = "0.2"
|
encoding = "0.2"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
urlencoding = "2.1.2"
|
urlencoding = "2.1.2"
|
||||||
|
|||||||
@@ -2,12 +2,10 @@ use regex::Regex;
|
|||||||
|
|
||||||
use crate::common::BitArray;
|
use crate::common::BitArray;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
lazy_static! {
|
static SPACES: Lazy<Regex> = Lazy::new(|| Regex::new("\\s+").unwrap());
|
||||||
static ref SPACES: Regex = Regex::new("\\s+").unwrap();
|
static DOTX: Lazy<Regex> = Lazy::new(|| Regex::new("[^.X]").unwrap());
|
||||||
static ref DOTX: Regex = Regex::new("[^.X]").unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn toBitArray(bits: &str) -> BitArray {
|
pub fn toBitArray(bits: &str) -> BitArray {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
use chrono::{DateTime, NaiveDateTime, TimeZone, Utc};
|
use chrono::{DateTime, NaiveDateTime, TimeZone, Utc};
|
||||||
use chrono_tz::Tz;
|
use chrono_tz::Tz;
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
use crate::exceptions::Exceptions;
|
use crate::exceptions::Exceptions;
|
||||||
@@ -46,11 +46,11 @@ const RFC2445_DURATION_FIELD_UNITS: [i64; 5] = [
|
|||||||
1000i64, // 1 second
|
1000i64, // 1 second
|
||||||
];
|
];
|
||||||
|
|
||||||
lazy_static! {
|
static DATE_TIME: Lazy<Regex> = Lazy::new(|| Regex::new("[0-9]{8}(T[0-9]{6}Z?)?").unwrap());
|
||||||
static ref DATE_TIME: Regex = Regex::new("[0-9]{8}(T[0-9]{6}Z?)?").unwrap();
|
static RFC2445_DURATION: Lazy<Regex> = Lazy::new(|| {
|
||||||
static ref RFC2445_DURATION: Regex =
|
Regex::new("P(?:(\\d+)W)?(?:(\\d+)D)?(?:T(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+)S)?)?").unwrap()
|
||||||
Regex::new("P(?:(\\d+)W)?(?:(\\d+)D)?(?:T(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+)S)?)?").unwrap();
|
});
|
||||||
}
|
|
||||||
// const DATE_TIME: &'static str = "[0-9]{8}(T[0-9]{6}Z?)?";
|
// const DATE_TIME: &'static str = "[0-9]{8}(T[0-9]{6}Z?)?";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -24,13 +24,11 @@
|
|||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
use crate::RXingResult;
|
use crate::RXingResult;
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
lazy_static! {
|
static COMMA: Lazy<Regex> = Lazy::new(|| Regex::new(",").unwrap());
|
||||||
static ref COMMA: Regex = Regex::new(",").unwrap();
|
static ATEXT_ALPHANUMERIC: Lazy<Regex> =
|
||||||
static ref ATEXT_ALPHANUMERIC: Regex =
|
Lazy::new(|| Regex::new("[a-zA-Z0-9@.!#$%&'*+\\-/=?^_`{|}~]+").unwrap());
|
||||||
Regex::new("[a-zA-Z0-9@.!#$%&'*+\\-/=?^_`{|}~]+").unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
EmailAddressParsedRXingResult, EmailDoCoMoResultParser, ParsedClientResult, ResultParser,
|
EmailAddressParsedRXingResult, EmailDoCoMoResultParser, ParsedClientResult, ResultParser,
|
||||||
|
|||||||
@@ -26,12 +26,10 @@ use crate::RXingResult;
|
|||||||
|
|
||||||
use super::{EmailAddressParsedRXingResult, ParsedClientResult, ResultParser};
|
use super::{EmailAddressParsedRXingResult, ParsedClientResult, ResultParser};
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
lazy_static! {
|
static ATEXT_ALPHANUMERIC: Lazy<Regex> =
|
||||||
static ref ATEXT_ALPHANUMERIC: Regex =
|
Lazy::new(|| Regex::new("[a-zA-Z0-9@.!#$%&'*+\\-/=?^_`{|}~]+").unwrap());
|
||||||
Regex::new("[a-zA-Z0-9@.!#$%&'*+\\-/=?^_`{|}~]+").unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements the "MATMSG" email message entry format.
|
* Implements the "MATMSG" email message entry format.
|
||||||
|
|||||||
@@ -23,11 +23,9 @@
|
|||||||
|
|
||||||
use super::{GeoParsedRXingResult, ParsedClientResult, ResultParser};
|
use super::{GeoParsedRXingResult, ParsedClientResult, ResultParser};
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
lazy_static! {
|
static GEO_URL: Lazy<regex::Regex> = Lazy::new(|| regex::Regex::new(GEO_URL_PATTERN).unwrap());
|
||||||
static ref GEO_URL: regex::Regex = regex::Regex::new(GEO_URL_PATTERN).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
const GEO_URL_PATTERN: &str = "geo:([\\-0-9.]+),([\\-0-9.]+)(?:,([\\-0-9.]+))?(?:\\?(.*))?";
|
const GEO_URL_PATTERN: &str = "geo:([\\-0-9.]+),([\\-0-9.]+)(?:,([\\-0-9.]+))?(?:\\?(.*))?";
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ use std::collections::HashMap;
|
|||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use urlencoding::decode;
|
use urlencoding::decode;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use crate::{exceptions::Exceptions, RXingResult};
|
use crate::{exceptions::Exceptions, RXingResult};
|
||||||
|
|
||||||
@@ -92,9 +92,7 @@ use super::{
|
|||||||
|
|
||||||
pub type ParserFunction = dyn Fn(&RXingResult) -> Option<ParsedClientResult>;
|
pub type ParserFunction = dyn Fn(&RXingResult) -> Option<ParsedClientResult>;
|
||||||
|
|
||||||
lazy_static! {
|
static DIGITS: Lazy<Regex> = Lazy::new(|| Regex::new("\\d+").unwrap());
|
||||||
static ref DIGITS: Regex = Regex::new("\\d+").unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
// const DIGITS: &'static str = "\\d+"; //= Pattern.compile("\\d+");
|
// const DIGITS: &'static str = "\\d+"; //= Pattern.compile("\\d+");
|
||||||
const AMPERSAND: &str = "&"; // private static final Pattern AMPERSAND = Pattern.compile("&");
|
const AMPERSAND: &str = "&"; // private static final Pattern AMPERSAND = Pattern.compile("&");
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
// import java.util.regex.Matcher;
|
// import java.util.regex.Matcher;
|
||||||
// import java.util.regex.Pattern;
|
// import java.util.regex.Pattern;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
/**
|
/**
|
||||||
* Tries to parse results that are a URI of some kind.
|
* Tries to parse results that are a URI of some kind.
|
||||||
*
|
*
|
||||||
@@ -34,15 +34,15 @@ use crate::RXingResult;
|
|||||||
|
|
||||||
use super::{ParsedClientResult, ResultParser, URIParsedRXingResult};
|
use super::{ParsedClientResult, ResultParser, URIParsedRXingResult};
|
||||||
|
|
||||||
lazy_static! {
|
static ALLOWED_URI_CHARS: Lazy<Regex> = Lazy::new(|| {
|
||||||
static ref ALLOWED_URI_CHARS: Regex =
|
Regex::new(ALLOWED_URI_CHARS_PATTERN).expect("Regex patterns should always copile")
|
||||||
Regex::new(ALLOWED_URI_CHARS_PATTERN).expect("Regex patterns should always copile");
|
});
|
||||||
static ref USER_IN_HOST: Regex =
|
static USER_IN_HOST: Lazy<Regex> =
|
||||||
Regex::new(":/*([^/@]+)@[^/]+").expect("Regex patterns should always copile");
|
Lazy::new(|| Regex::new(":/*([^/@]+)@[^/]+").expect("Regex patterns should always copile"));
|
||||||
static ref URL_WITH_PROTOCOL_PATTERN: Regex = Regex::new("[a-zA-Z][a-zA-Z0-9+-.]+:").unwrap();
|
static URL_WITH_PROTOCOL_PATTERN: Lazy<Regex> =
|
||||||
static ref URL_WITHOUT_PROTOCOL_PATTERN: Regex =
|
Lazy::new(|| Regex::new("[a-zA-Z][a-zA-Z0-9+-.]+:").unwrap());
|
||||||
Regex::new("([a-zA-Z0-9\\-]+\\.){1,6}[a-zA-Z]{2,}(:\\d{1,5})?(/|\\?|$)").unwrap();
|
static URL_WITHOUT_PROTOCOL_PATTERN: Lazy<Regex> =
|
||||||
}
|
Lazy::new(|| Regex::new("([a-zA-Z0-9\\-]+\\.){1,6}[a-zA-Z]{2,}(:\\d{1,5})?(/|\\?|$)").unwrap());
|
||||||
|
|
||||||
const ALLOWED_URI_CHARS_PATTERN: &str = "[-._~:/?#\\[\\]@!$&'()*+,;=%A-Za-z0-9]+";
|
const ALLOWED_URI_CHARS_PATTERN: &str = "[-._~:/?#\\[\\]@!$&'()*+,;=%A-Za-z0-9]+";
|
||||||
// const USER_IN_HOST: &'static str = ":/*([^/@]+)@[^/]+";
|
// const USER_IN_HOST: &'static str = ":/*([^/@]+)@[^/]+";
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ use std::convert::TryFrom;
|
|||||||
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use crate::RXingResult;
|
use crate::RXingResult;
|
||||||
|
|
||||||
@@ -40,17 +40,15 @@ use uriparse::URI;
|
|||||||
|
|
||||||
use super::{AddressBookParsedRXingResult, ParsedClientResult, ResultParser};
|
use super::{AddressBookParsedRXingResult, ParsedClientResult, ResultParser};
|
||||||
|
|
||||||
lazy_static! {
|
static BEGIN_VCARD: Lazy<Regex> = Lazy::new(|| Regex::new("(?i:BEGIN:VCARD)").unwrap());
|
||||||
static ref BEGIN_VCARD: Regex = Regex::new("(?i:BEGIN:VCARD)").unwrap();
|
static VCARD_LIKE_DATE: Lazy<Regex> = Lazy::new(|| Regex::new("\\d{4}-?\\d{2}-?\\d{2}").unwrap());
|
||||||
static ref VCARD_LIKE_DATE: Regex = Regex::new("\\d{4}-?\\d{2}-?\\d{2}").unwrap();
|
static CR_LF_SPACE_TAB: Lazy<Regex> = Lazy::new(|| Regex::new("\r\n[ \t]").unwrap());
|
||||||
static ref CR_LF_SPACE_TAB: Regex = Regex::new("\r\n[ \t]").unwrap();
|
static NEWLINE_ESCAPE: Lazy<Regex> = Lazy::new(|| Regex::new("\\\\[nN]").unwrap());
|
||||||
static ref NEWLINE_ESCAPE: Regex = Regex::new("\\\\[nN]").unwrap();
|
static VCARD_ESCAPE: Lazy<Regex> = Lazy::new(|| Regex::new("\\\\([,;\\\\])").unwrap());
|
||||||
static ref VCARD_ESCAPE: Regex = Regex::new("\\\\([,;\\\\])").unwrap();
|
static EQUALS: Lazy<Regex> = Lazy::new(|| Regex::new("=").unwrap());
|
||||||
static ref EQUALS: Regex = Regex::new("=").unwrap();
|
static UNESCAPED_SEMICOLONS: Lazy<fancy_regex::Regex> =
|
||||||
static ref UNESCAPED_SEMICOLONS: fancy_regex::Regex =
|
Lazy::new(|| fancy_regex::Regex::new("(?<!\\\\);+").unwrap());
|
||||||
fancy_regex::Regex::new("(?<!\\\\);+").unwrap();
|
static SEMICOLON_OR_COMMA: Lazy<Regex> = Lazy::new(|| Regex::new("[;,]").unwrap());
|
||||||
static ref SEMICOLON_OR_COMMA: Regex = Regex::new("[;,]").unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
// const BEGIN_VCARD: &'static str = "(?i:BEGIN:VCARD)"; //, Pattern.CASE_INSENSITIVE);
|
// const BEGIN_VCARD: &'static str = "(?i:BEGIN:VCARD)"; //, Pattern.CASE_INSENSITIVE);
|
||||||
// const VCARD_LIKE_DATE: &'static str = "\\d{4}-?\\d{2}-?\\d{2}";
|
// const VCARD_LIKE_DATE: &'static str = "\\d{4}-?\\d{2}-?\\d{2}";
|
||||||
|
|||||||
@@ -29,12 +29,10 @@ use crate::{
|
|||||||
|
|
||||||
use super::ParsedClientResult;
|
use super::ParsedClientResult;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
lazy_static! {
|
static IOQ_MATCHER: Lazy<Regex> = Lazy::new(|| Regex::new(IOQ).unwrap());
|
||||||
static ref IOQ_MATCHER: Regex = Regex::new(IOQ).unwrap();
|
static AZ09_MATCHER: Lazy<Regex> = Lazy::new(|| Regex::new(AZ09).unwrap());
|
||||||
static ref AZ09_MATCHER: Regex = Regex::new(AZ09).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detects a result that is likely a vehicle identification number.
|
* Detects a result that is likely a vehicle identification number.
|
||||||
|
|||||||
@@ -56,11 +56,7 @@ fn test_short_shift_jis1() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_short_iso885911() {
|
fn test_short_iso885911() {
|
||||||
// båd
|
// båd
|
||||||
do_test(
|
do_test(&[0x62, 0xe5, 0x64], encoding::all::ISO_8859_1, "ISO8859_1");
|
||||||
&[0x62, 0xe5, 0x64],
|
|
||||||
encoding::all::ISO_8859_1,
|
|
||||||
"ISO8859_1",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -28,10 +28,9 @@ use unicode_segmentation::UnicodeSegmentation;
|
|||||||
|
|
||||||
use super::CharacterSetECI;
|
use super::CharacterSetECI;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
lazy_static! {
|
static ENCODERS: Lazy<Vec<EncodingRef>> = Lazy::new(|| {
|
||||||
static ref ENCODERS : Vec<EncodingRef> = {
|
|
||||||
let mut enc_vec = Vec::new();
|
let mut enc_vec = Vec::new();
|
||||||
for name in NAMES {
|
for name in NAMES {
|
||||||
if let Some(enc) = CharacterSetECI::getCharacterSetECIByName(name) {
|
if let Some(enc) = CharacterSetECI::getCharacterSetECIByName(name) {
|
||||||
@@ -43,8 +42,8 @@ lazy_static! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
enc_vec
|
enc_vec
|
||||||
};
|
});
|
||||||
}
|
|
||||||
const NAMES: [&str; 20] = [
|
const NAMES: [&str; 20] = [
|
||||||
"IBM437",
|
"IBM437",
|
||||||
"ISO-8859-2",
|
"ISO-8859-2",
|
||||||
|
|||||||
@@ -22,18 +22,14 @@ pub(crate) mod ReedSolomonTestCase;
|
|||||||
//package com.google.zxing.common.reedsolomon;
|
//package com.google.zxing.common.reedsolomon;
|
||||||
|
|
||||||
pub type GenericGFRef = &'static GenericGF;
|
pub type GenericGFRef = &'static GenericGF;
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
static AZTEC_DATA_12: Lazy<GenericGF> = Lazy::new(|| GenericGF::new(0x1069, 4096, 1)); // x^12 + x^6 + x^5 + x^3 + 1
|
||||||
|
static AZTEC_DATA_10: Lazy<GenericGF> = Lazy::new(|| GenericGF::new(0x409, 1024, 1)); // x^10 + x^3 + 1
|
||||||
lazy_static! {
|
static AZTEC_DATA_6: Lazy<GenericGF> = Lazy::new(|| GenericGF::new(0x43, 64, 1)); // x^6 + x + 1
|
||||||
static ref AZTEC_DATA_12: GenericGF = GenericGF::new(0x1069, 4096, 1); // x^12 + x^6 + x^5 + x^3 + 1
|
static AZTEC_PARAM: Lazy<GenericGF> = Lazy::new(|| GenericGF::new(0x13, 16, 1)); // x^4 + x + 1
|
||||||
static ref AZTEC_DATA_10: GenericGF = GenericGF::new(0x409, 1024, 1); // x^10 + x^3 + 1
|
static QR_CODE_FIELD_256: Lazy<GenericGF> = Lazy::new(|| GenericGF::new(0x011D, 256, 0)); // x^8 + x^4 + x^3 + x^2 + 1
|
||||||
static ref AZTEC_DATA_6: GenericGF = GenericGF::new(0x43, 64, 1); // x^6 + x + 1
|
static DATA_MATRIX_FIELD_256: Lazy<GenericGF> = Lazy::new(|| GenericGF::new(0x012D, 256, 1)); // x^8 + x^5 + x^3 + x^2 + 1
|
||||||
static ref AZTEC_PARAM: GenericGF = GenericGF::new(0x13, 16, 1); // x^4 + x + 1
|
|
||||||
static ref QR_CODE_FIELD_256: GenericGF = GenericGF::new(0x011D, 256, 0); // x^8 + x^4 + x^3 + x^2 + 1
|
|
||||||
static ref DATA_MATRIX_FIELD_256: GenericGF = GenericGF::new(0x012D, 256, 1); // x^8 + x^5 + x^3 + x^2 + 1
|
|
||||||
// static ref PDF_417_FIELD: GenericGF = GenericGF::new(3,crate::pdf417::pdf_417_common::NUMBER_OF_CODEWORDS as usize,1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// pub const AZTEC_DATA_12: GenericGF = GenericGF::new(0x1069, 4096, 1); // x^12 + x^6 + x^5 + x^3 + 1
|
// pub const AZTEC_DATA_12: GenericGF = GenericGF::new(0x1069, 4096, 1); // x^12 + x^6 + x^5 + x^3 + 1
|
||||||
// pub const AZTEC_DATA_10: GenericGF = GenericGF::new(0x409, 1024, 1); // x^10 + x^3 + 1
|
// pub const AZTEC_DATA_10: GenericGF = GenericGF::new(0x409, 1024, 1); // x^10 + x^3 + 1
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ use encoding::{Encoding, EncodingRef};
|
|||||||
|
|
||||||
use crate::{DecodeHintType, DecodeHintValue, DecodingHintDictionary};
|
use crate::{DecodeHintType, DecodeHintValue, DecodingHintDictionary};
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common string-related functions.
|
* Common string-related functions.
|
||||||
@@ -55,10 +55,9 @@ pub struct StringUtils {
|
|||||||
const ASSUME_SHIFT_JIS: bool = false;
|
const ASSUME_SHIFT_JIS: bool = false;
|
||||||
// static SHIFT_JIS: &'static str = "SJIS";
|
// static SHIFT_JIS: &'static str = "SJIS";
|
||||||
// static GB2312: &'static str = "GB2312";
|
// static GB2312: &'static str = "GB2312";
|
||||||
lazy_static! {
|
|
||||||
pub static ref SHIFT_JIS_CHARSET: EncodingRef =
|
pub static SHIFT_JIS_CHARSET: Lazy<EncodingRef> =
|
||||||
encoding::label::encoding_from_whatwg_label("SJIS").unwrap();
|
Lazy::new(|| encoding::label::encoding_from_whatwg_label("SJIS").unwrap());
|
||||||
}
|
|
||||||
|
|
||||||
// private static final boolean ASSUME_SHIFT_JIS =
|
// private static final boolean ASSUME_SHIFT_JIS =
|
||||||
// SHIFT_JIS_CHARSET.equals(PLATFORM_DEFAULT_ENCODING) ||
|
// SHIFT_JIS_CHARSET.equals(PLATFORM_DEFAULT_ENCODING) ||
|
||||||
|
|||||||
@@ -24,11 +24,9 @@ use crate::{
|
|||||||
|
|
||||||
use super::{decoder::Decoder, detector::Detector};
|
use super::{decoder::Decoder, detector::Detector};
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
lazy_static! {
|
static DECODER: Lazy<Decoder> = Lazy::new(|| Decoder::new());
|
||||||
static ref DECODER: Decoder = Decoder::new();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This implementation can detect and decode Data Matrix codes in an image.
|
* This implementation can detect and decode Data Matrix codes in an image.
|
||||||
|
|||||||
@@ -15,13 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use crate::Exceptions;
|
use crate::Exceptions;
|
||||||
|
|
||||||
lazy_static! {
|
static VERSIONS: Lazy<Vec<Version>> = Lazy::new(|| Version::buildVersions());
|
||||||
static ref VERSIONS: Vec<Version> = Version::buildVersions();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type VersionRef = &'static Version;
|
pub type VersionRef = &'static Version;
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use crate::Exceptions;
|
|||||||
|
|
||||||
use super::SymbolInfo;
|
use super::SymbolInfo;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error Correction Code for ECC200.
|
* Error Correction Code for ECC200.
|
||||||
@@ -30,11 +30,11 @@ use lazy_static::lazy_static;
|
|||||||
*/
|
*/
|
||||||
const FACTOR_SETS: [u32; 16] = [5, 7, 10, 11, 12, 14, 18, 20, 24, 28, 36, 42, 48, 56, 62, 68];
|
const FACTOR_SETS: [u32; 16] = [5, 7, 10, 11, 12, 14, 18, 20, 24, 28, 36, 42, 48, 56, 62, 68];
|
||||||
|
|
||||||
lazy_static! {
|
|
||||||
/**
|
/**
|
||||||
* Precomputed polynomial factors for ECC 200.
|
* Precomputed polynomial factors for ECC 200.
|
||||||
*/
|
*/
|
||||||
static ref FACTORS: [Vec<u32>; 16] = [
|
static FACTORS: Lazy<[Vec<u32>; 16]> = Lazy::new(|| {
|
||||||
|
[
|
||||||
Vec::from([228, 48, 15, 111, 62]),
|
Vec::from([228, 48, 15, 111, 62]),
|
||||||
Vec::from([23, 68, 144, 134, 240, 92, 254]),
|
Vec::from([23, 68, 144, 134, 240, 92, 254]),
|
||||||
Vec::from([28, 24, 185, 166, 223, 248, 116, 255, 110, 61]),
|
Vec::from([28, 24, 185, 166, 223, 248, 116, 255, 110, 61]),
|
||||||
@@ -47,49 +47,51 @@ static ref FACTORS: [Vec<u32>; 16] = [
|
|||||||
83, 195, 100, 39, 188, 75, 66, 61, 241, 213, 109, 129, 94, 254, 225, 48, 90, 188,
|
83, 195, 100, 39, 188, 75, 66, 61, 241, 213, 109, 129, 94, 254, 225, 48, 90, 188,
|
||||||
]),
|
]),
|
||||||
Vec::from([
|
Vec::from([
|
||||||
15, 195, 244, 9, 233, 71, 168, 2, 188, 160, 153, 145, 253, 79, 108, 82, 27, 174, 186, 172,
|
15, 195, 244, 9, 233, 71, 168, 2, 188, 160, 153, 145, 253, 79, 108, 82, 27, 174, 186,
|
||||||
|
172,
|
||||||
]),
|
]),
|
||||||
Vec::from([
|
Vec::from([
|
||||||
52, 190, 88, 205, 109, 39, 176, 21, 155, 197, 251, 223, 155, 21, 5, 172, 254, 124, 12, 181,
|
52, 190, 88, 205, 109, 39, 176, 21, 155, 197, 251, 223, 155, 21, 5, 172, 254, 124, 12,
|
||||||
184, 96, 50, 193,
|
181, 184, 96, 50, 193,
|
||||||
]),
|
]),
|
||||||
Vec::from([
|
Vec::from([
|
||||||
211, 231, 43, 97, 71, 96, 103, 174, 37, 151, 170, 53, 75, 34, 249, 121, 17, 138, 110, 213,
|
211, 231, 43, 97, 71, 96, 103, 174, 37, 151, 170, 53, 75, 34, 249, 121, 17, 138, 110,
|
||||||
141, 136, 120, 151, 233, 168, 93, 255,
|
213, 141, 136, 120, 151, 233, 168, 93, 255,
|
||||||
]),
|
]),
|
||||||
Vec::from([
|
Vec::from([
|
||||||
245, 127, 242, 218, 130, 250, 162, 181, 102, 120, 84, 179, 220, 251, 80, 182, 229, 18, 2,
|
245, 127, 242, 218, 130, 250, 162, 181, 102, 120, 84, 179, 220, 251, 80, 182, 229, 18,
|
||||||
4, 68, 33, 101, 137, 95, 119, 115, 44, 175, 184, 59, 25, 225, 98, 81, 112,
|
2, 4, 68, 33, 101, 137, 95, 119, 115, 44, 175, 184, 59, 25, 225, 98, 81, 112,
|
||||||
]),
|
]),
|
||||||
Vec::from([
|
Vec::from([
|
||||||
77, 193, 137, 31, 19, 38, 22, 153, 247, 105, 122, 2, 245, 133, 242, 8, 175, 95, 100, 9,
|
77, 193, 137, 31, 19, 38, 22, 153, 247, 105, 122, 2, 245, 133, 242, 8, 175, 95, 100, 9,
|
||||||
167, 105, 214, 111, 57, 121, 21, 1, 253, 57, 54, 101, 248, 202, 69, 50, 150, 177, 226, 5,
|
167, 105, 214, 111, 57, 121, 21, 1, 253, 57, 54, 101, 248, 202, 69, 50, 150, 177, 226,
|
||||||
9, 5,
|
5, 9, 5,
|
||||||
]),
|
]),
|
||||||
Vec::from([
|
Vec::from([
|
||||||
245, 132, 172, 223, 96, 32, 117, 22, 238, 133, 238, 231, 205, 188, 237, 87, 191, 106, 16,
|
245, 132, 172, 223, 96, 32, 117, 22, 238, 133, 238, 231, 205, 188, 237, 87, 191, 106,
|
||||||
147, 118, 23, 37, 90, 170, 205, 131, 88, 120, 100, 66, 138, 186, 240, 82, 44, 176, 87, 187,
|
16, 147, 118, 23, 37, 90, 170, 205, 131, 88, 120, 100, 66, 138, 186, 240, 82, 44, 176,
|
||||||
147, 160, 175, 69, 213, 92, 253, 225, 19,
|
87, 187, 147, 160, 175, 69, 213, 92, 253, 225, 19,
|
||||||
]),
|
]),
|
||||||
Vec::from([
|
Vec::from([
|
||||||
175, 9, 223, 238, 12, 17, 220, 208, 100, 29, 175, 170, 230, 192, 215, 235, 150, 159, 36,
|
175, 9, 223, 238, 12, 17, 220, 208, 100, 29, 175, 170, 230, 192, 215, 235, 150, 159,
|
||||||
223, 38, 200, 132, 54, 228, 146, 218, 234, 117, 203, 29, 232, 144, 238, 22, 150, 201, 117,
|
36, 223, 38, 200, 132, 54, 228, 146, 218, 234, 117, 203, 29, 232, 144, 238, 22, 150,
|
||||||
62, 207, 164, 13, 137, 245, 127, 67, 247, 28, 155, 43, 203, 107, 233, 53, 143, 46,
|
201, 117, 62, 207, 164, 13, 137, 245, 127, 67, 247, 28, 155, 43, 203, 107, 233, 53,
|
||||||
|
143, 46,
|
||||||
]),
|
]),
|
||||||
Vec::from([
|
Vec::from([
|
||||||
242, 93, 169, 50, 144, 210, 39, 118, 202, 188, 201, 189, 143, 108, 196, 37, 185, 112, 134,
|
242, 93, 169, 50, 144, 210, 39, 118, 202, 188, 201, 189, 143, 108, 196, 37, 185, 112,
|
||||||
230, 245, 63, 197, 190, 250, 106, 185, 221, 175, 64, 114, 71, 161, 44, 147, 6, 27, 218, 51,
|
134, 230, 245, 63, 197, 190, 250, 106, 185, 221, 175, 64, 114, 71, 161, 44, 147, 6, 27,
|
||||||
63, 87, 10, 40, 130, 188, 17, 163, 31, 176, 170, 4, 107, 232, 7, 94, 166, 224, 124, 86, 47,
|
218, 51, 63, 87, 10, 40, 130, 188, 17, 163, 31, 176, 170, 4, 107, 232, 7, 94, 166, 224,
|
||||||
11, 204,
|
124, 86, 47, 11, 204,
|
||||||
]),
|
]),
|
||||||
Vec::from([
|
Vec::from([
|
||||||
220, 228, 173, 89, 251, 149, 159, 56, 89, 33, 147, 244, 154, 36, 73, 127, 213, 136, 248,
|
220, 228, 173, 89, 251, 149, 159, 56, 89, 33, 147, 244, 154, 36, 73, 127, 213, 136,
|
||||||
180, 234, 197, 158, 177, 68, 122, 93, 213, 15, 160, 227, 236, 66, 139, 153, 185, 202, 167,
|
248, 180, 234, 197, 158, 177, 68, 122, 93, 213, 15, 160, 227, 236, 66, 139, 153, 185,
|
||||||
179, 25, 220, 232, 96, 210, 231, 136, 223, 239, 181, 241, 59, 52, 172, 25, 49, 232, 211,
|
202, 167, 179, 25, 220, 232, 96, 210, 231, 136, 223, 239, 181, 241, 59, 52, 172, 25,
|
||||||
189, 64, 54, 108, 153, 132, 63, 96, 103, 82, 186,
|
49, 232, 211, 189, 64, 54, 108, 153, 132, 63, 96, 103, 82, 186,
|
||||||
]),
|
]),
|
||||||
];
|
]
|
||||||
}
|
});
|
||||||
|
|
||||||
const MODULO_VALUE: usize = 0x12D;
|
const MODULO_VALUE: usize = 0x12D;
|
||||||
|
|
||||||
|
|||||||
@@ -16,27 +16,26 @@
|
|||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use crate::datamatrix::encoder::{SymbolInfo, SymbolShapeHint};
|
use crate::datamatrix::encoder::{SymbolInfo, SymbolShapeHint};
|
||||||
|
|
||||||
use super::{high_level_encoder, minimal_encoder, symbol_info, SymbolInfoLookup};
|
use super::{high_level_encoder, minimal_encoder, symbol_info, SymbolInfoLookup};
|
||||||
|
|
||||||
lazy_static! {
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link HighLevelEncoder} and {@link MinimalEncoder}
|
* Tests for {@link HighLevelEncoder} and {@link MinimalEncoder}
|
||||||
*/
|
*/
|
||||||
static ref TEST_SYMBOLS :Vec<SymbolInfo>= vec![
|
static TEST_SYMBOLS: Lazy<Vec<SymbolInfo>> = Lazy::new(|| {
|
||||||
|
vec![
|
||||||
SymbolInfo::new(false, 3, 5, 8, 8, 1),
|
SymbolInfo::new(false, 3, 5, 8, 8, 1),
|
||||||
SymbolInfo::new(false, 5, 7, 10, 10, 1),
|
SymbolInfo::new(false, 5, 7, 10, 10, 1),
|
||||||
/*rect*/ SymbolInfo::new(true, 5, 7, 16, 6, 1),
|
/*rect*/ SymbolInfo::new(true, 5, 7, 16, 6, 1),
|
||||||
SymbolInfo::new(false, 8, 10, 12, 12, 1),
|
SymbolInfo::new(false, 8, 10, 12, 12, 1),
|
||||||
/*rect*/ SymbolInfo::new(true, 10, 11, 14, 6, 2),
|
/*rect*/ SymbolInfo::new(true, 10, 11, 14, 6, 2),
|
||||||
SymbolInfo::new(false, 13, 0, 0, 0, 1),
|
SymbolInfo::new(false, 13, 0, 0, 0, 1),
|
||||||
SymbolInfo::new(false, 77, 0, 0, 0, 1)
|
SymbolInfo::new(false, 77, 0, 0, 0, 1), //The last entries are fake entries to test special conditions with C40 encoding
|
||||||
//The last entries are fake entries to test special conditions with C40 encoding
|
]
|
||||||
];
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// const SIL: SymbolInfoLookup = SymbolInfoLookup::new();
|
// const SIL: SymbolInfoLookup = SymbolInfoLookup::new();
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ use std::fmt;
|
|||||||
use crate::{Dimension, Exceptions};
|
use crate::{Dimension, Exceptions};
|
||||||
|
|
||||||
use super::SymbolShapeHint;
|
use super::SymbolShapeHint;
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
lazy_static! {
|
pub(super) static PROD_SYMBOLS: Lazy<Vec<SymbolInfo>> = Lazy::new(|| {
|
||||||
pub(super) static ref PROD_SYMBOLS: Vec<SymbolInfo> = vec![
|
vec![
|
||||||
SymbolInfo::new(false, 3, 5, 8, 8, 1),
|
SymbolInfo::new(false, 3, 5, 8, 8, 1),
|
||||||
SymbolInfo::new(false, 5, 7, 10, 10, 1),
|
SymbolInfo::new(false, 5, 7, 10, 10, 1),
|
||||||
/*rect*/ SymbolInfo::new(true, 5, 7, 16, 6, 1),
|
/*rect*/ SymbolInfo::new(true, 5, 7, 16, 6, 1),
|
||||||
@@ -53,8 +53,8 @@ pub(super) static ref PROD_SYMBOLS: Vec<SymbolInfo> = vec![
|
|||||||
SymbolInfo::with_details(false, 1050, 408, 18, 18, 36, 175, 68),
|
SymbolInfo::with_details(false, 1050, 408, 18, 18, 36, 175, 68),
|
||||||
SymbolInfo::with_details(false, 1304, 496, 20, 20, 36, 163, 62),
|
SymbolInfo::with_details(false, 1304, 496, 20, 20, 36, 163, 62),
|
||||||
SymbolInfo::new_symbol_info_144(),
|
SymbolInfo::new_symbol_info_144(),
|
||||||
];
|
]
|
||||||
}
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Symbol info table for DataMatrix.
|
* Symbol info table for DataMatrix.
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ pub fn detect_in_file_with_hints(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
hints.entry(DecodeHintType::TRY_HARDER).or_insert(DecodeHintValue::TryHarder(true));
|
hints
|
||||||
|
.entry(DecodeHintType::TRY_HARDER)
|
||||||
|
.or_insert(DecodeHintValue::TryHarder(true));
|
||||||
|
|
||||||
multi_format_reader.decode_with_hints(
|
multi_format_reader.decode_with_hints(
|
||||||
&mut BinaryBitmap::new(Rc::new(RefCell::new(HybridBinarizer::new(Box::new(
|
&mut BinaryBitmap::new(Rc::new(RefCell::new(HybridBinarizer::new(Box::new(
|
||||||
@@ -60,7 +62,9 @@ pub fn detect_multiple_in_file_with_hints(
|
|||||||
let multi_format_reader = MultiFormatReader::default();
|
let multi_format_reader = MultiFormatReader::default();
|
||||||
let mut scanner = GenericMultipleBarcodeReader::new(multi_format_reader);
|
let mut scanner = GenericMultipleBarcodeReader::new(multi_format_reader);
|
||||||
|
|
||||||
hints.entry(DecodeHintType::TRY_HARDER).or_insert(DecodeHintValue::TryHarder(true));
|
hints
|
||||||
|
.entry(DecodeHintType::TRY_HARDER)
|
||||||
|
.or_insert(DecodeHintValue::TryHarder(true));
|
||||||
|
|
||||||
scanner.decode_multiple_with_hints(
|
scanner.decode_multiple_with_hints(
|
||||||
&mut BinaryBitmap::new(Rc::new(RefCell::new(HybridBinarizer::new(Box::new(
|
&mut BinaryBitmap::new(Rc::new(RefCell::new(HybridBinarizer::new(Box::new(
|
||||||
@@ -95,7 +99,9 @@ pub fn detect_in_luma_with_hints(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
hints.entry(DecodeHintType::TRY_HARDER).or_insert(DecodeHintValue::TryHarder(true));
|
hints
|
||||||
|
.entry(DecodeHintType::TRY_HARDER)
|
||||||
|
.or_insert(DecodeHintValue::TryHarder(true));
|
||||||
|
|
||||||
multi_format_reader.decode_with_hints(
|
multi_format_reader.decode_with_hints(
|
||||||
&mut BinaryBitmap::new(Rc::new(RefCell::new(HybridBinarizer::new(Box::new(
|
&mut BinaryBitmap::new(Rc::new(RefCell::new(HybridBinarizer::new(Box::new(
|
||||||
@@ -122,7 +128,9 @@ pub fn detect_multiple_in_luma_with_hints(
|
|||||||
let multi_format_reader = MultiFormatReader::default();
|
let multi_format_reader = MultiFormatReader::default();
|
||||||
let mut scanner = GenericMultipleBarcodeReader::new(multi_format_reader);
|
let mut scanner = GenericMultipleBarcodeReader::new(multi_format_reader);
|
||||||
|
|
||||||
hints.entry(DecodeHintType::TRY_HARDER).or_insert(DecodeHintValue::TryHarder(true));
|
hints
|
||||||
|
.entry(DecodeHintType::TRY_HARDER)
|
||||||
|
.or_insert(DecodeHintValue::TryHarder(true));
|
||||||
|
|
||||||
scanner.decode_multiple_with_hints(
|
scanner.decode_multiple_with_hints(
|
||||||
&mut BinaryBitmap::new(Rc::new(RefCell::new(HybridBinarizer::new(Box::new(
|
&mut BinaryBitmap::new(Rc::new(RefCell::new(HybridBinarizer::new(Box::new(
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
|
|
||||||
use crate::{common::DecoderRXingResult, Exceptions};
|
use crate::{common::DecoderRXingResult, Exceptions};
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>MaxiCodes can encode text or structured information as bits in one of several modes,
|
* <p>MaxiCodes can encode text or structured information as bits in one of several modes,
|
||||||
@@ -59,8 +59,8 @@ const POSTCODE_3_BYTES: [[u8; 6]; 6] = [
|
|||||||
[9, 10, 11, 12, 1, 2],
|
[9, 10, 11, 12, 1, 2],
|
||||||
];
|
];
|
||||||
|
|
||||||
lazy_static! {
|
static SETS: Lazy<[String; 5]> = Lazy::new(|| {
|
||||||
static ref SETS : [String;5]= [
|
[
|
||||||
format!("\rABCDEFGHIJKLMNOPQRSTUVWXYZ{}{}{}{}{} {}\"#$%&'()*+,-./0123456789:{}{}{}{}{}" , ECI , FS , GS , RS , NS , PAD ,
|
format!("\rABCDEFGHIJKLMNOPQRSTUVWXYZ{}{}{}{}{} {}\"#$%&'()*+,-./0123456789:{}{}{}{}{}" , ECI , FS , GS , RS , NS , PAD ,
|
||||||
SHIFTB , SHIFTC , SHIFTD , SHIFTE , LATCHB),
|
SHIFTB , SHIFTC , SHIFTD , SHIFTE , LATCHB),
|
||||||
format!("`abcdefghijklmnopqrstuvwxyz{}{}{}{}{}{{{}}}~\u{007F};<=>?[\\]^_ ,./:@!|{}{}{}{}{}{}{}{}{}" , ECI , FS , GS , RS , NS ,PAD ,
|
format!("`abcdefghijklmnopqrstuvwxyz{}{}{}{}{}{{{}}}~\u{007F};<=>?[\\]^_ ,./:@!|{}{}{}{}{}{}{}{}{}" , ECI , FS , GS , RS , NS ,PAD ,
|
||||||
@@ -78,8 +78,8 @@ static ref SETS : [String;5]= [
|
|||||||
ECI , PAD , PAD , '\u{001B}' , NS , FS , GS , RS ,
|
ECI , PAD , PAD , '\u{001B}' , NS , FS , GS , RS ,
|
||||||
"\u{001F}\u{009F}\u{00A0}\u{00A2}\u{00A3}\u{00A4}\u{00A5}\u{00A6}\u{00A7}\u{00A9}\u{00AD}\u{00AE}\u{00B6}\u{0095}\u{0096}\u{0097}\u{0098}\u{0099}\u{009A}\u{009B}\u{009C}\u{009D}\u{009E}" ,
|
"\u{001F}\u{009F}\u{00A0}\u{00A2}\u{00A3}\u{00A4}\u{00A5}\u{00A6}\u{00A7}\u{00A9}\u{00AD}\u{00AE}\u{00B6}\u{0095}\u{0096}\u{0097}\u{0098}\u{0099}\u{009A}\u{009B}\u{009C}\u{009D}\u{009E}" ,
|
||||||
LATCHA , ' ' , SHIFTC , SHIFTD , LOCK , LATCHB),
|
LATCHA , ' ' , SHIFTC , SHIFTD , LOCK , LATCHB),
|
||||||
];
|
]
|
||||||
}
|
});
|
||||||
|
|
||||||
pub fn decode(bytes: &[u8], mode: u8) -> Result<DecoderRXingResult, Exceptions> {
|
pub fn decode(bytes: &[u8], mode: u8) -> Result<DecoderRXingResult, Exceptions> {
|
||||||
let mut result = String::with_capacity(144);
|
let mut result = String::with_capacity(144);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::{
|
common::{
|
||||||
@@ -39,11 +39,11 @@ const ALL: u32 = 0;
|
|||||||
const EVEN: u32 = 1;
|
const EVEN: u32 = 1;
|
||||||
const ODD: u32 = 2;
|
const ODD: u32 = 2;
|
||||||
|
|
||||||
lazy_static! {
|
static RS_DECODER: Lazy<ReedSolomonDecoder> = Lazy::new(|| {
|
||||||
static ref RS_DECODER: ReedSolomonDecoder = ReedSolomonDecoder::new(get_predefined_genericgf(
|
ReedSolomonDecoder::new(get_predefined_genericgf(
|
||||||
PredefinedGenericGF::MaxicodeField64
|
PredefinedGenericGF::MaxicodeField64,
|
||||||
));
|
))
|
||||||
}
|
});
|
||||||
|
|
||||||
pub fn decode(bits: BitMatrix) -> Result<DecoderRXingResult, Exceptions> {
|
pub fn decode(bits: BitMatrix) -> Result<DecoderRXingResult, Exceptions> {
|
||||||
decode_with_hints(bits, &HashMap::new())
|
decode_with_hints(bits, &HashMap::new())
|
||||||
|
|||||||
@@ -450,11 +450,10 @@ impl Code128Reader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
lazy_static! {
|
pub static CODE_PATTERNS: Lazy<[Vec<u32>; 107]> = Lazy::new(|| {
|
||||||
|
[
|
||||||
pub static ref CODE_PATTERNS: [Vec<u32>; 107] = [
|
|
||||||
vec![2, 1, 2, 2, 2, 2], // 0
|
vec![2, 1, 2, 2, 2, 2], // 0
|
||||||
vec![2, 2, 2, 1, 2, 2],
|
vec![2, 2, 2, 1, 2, 2],
|
||||||
vec![2, 2, 2, 2, 2, 1],
|
vec![2, 2, 2, 2, 2, 1],
|
||||||
@@ -562,8 +561,8 @@ pub static ref CODE_PATTERNS: [Vec<u32>; 107] = [
|
|||||||
vec![2, 1, 1, 2, 1, 4],
|
vec![2, 1, 1, 2, 1, 4],
|
||||||
vec![2, 1, 1, 2, 3, 2], // 105
|
vec![2, 1, 1, 2, 3, 2], // 105
|
||||||
vec![2, 3, 3, 1, 1, 1, 2],
|
vec![2, 3, 3, 1, 1, 1, 2],
|
||||||
];
|
]
|
||||||
}
|
});
|
||||||
|
|
||||||
const MAX_AVG_VARIANCE: f32 = 0.25;
|
const MAX_AVG_VARIANCE: f32 = 0.25;
|
||||||
const MAX_INDIVIDUAL_VARIANCE: f32 = 0.7;
|
const MAX_INDIVIDUAL_VARIANCE: f32 = 0.7;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ const LF: &str = "10000110010";
|
|||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::{BitMatrix, BitMatrixTestCase},
|
common::{BitMatrix, BitMatrixTestCase},
|
||||||
@@ -43,9 +43,8 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::Code128Writer;
|
use super::Code128Writer;
|
||||||
lazy_static! {
|
|
||||||
static ref WRITER: Code128Writer = Code128Writer::default();
|
static WRITER: Lazy<Code128Writer> = Lazy::new(|| Code128Writer::default());
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn testEncodeWithFunc3() {
|
fn testEncodeWithFunc3() {
|
||||||
|
|||||||
@@ -20,12 +20,10 @@ use crate::{
|
|||||||
common::BitMatrix, BarcodeFormat, EncodeHintType, EncodeHintValue, Exceptions, Writer,
|
common::BitMatrix, BarcodeFormat, EncodeHintType, EncodeHintValue, Exceptions, Writer,
|
||||||
};
|
};
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
lazy_static! {
|
pub static NUMERIC: Lazy<Regex> = Lazy::new(|| Regex::new("[0-9]+").unwrap());
|
||||||
pub static ref NUMERIC: Regex = Regex::new("[0-9]+").unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Encapsulates functionality and implementation that is common to one-dimensional barcodes.</p>
|
* <p>Encapsulates functionality and implementation that is common to one-dimensional barcodes.</p>
|
||||||
|
|||||||
@@ -27,16 +27,14 @@
|
|||||||
/**
|
/**
|
||||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||||
*/
|
*/
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
use crate::{common::BitArray, Exceptions};
|
use crate::{common::BitArray, Exceptions};
|
||||||
|
|
||||||
lazy_static! {
|
static ONE: Lazy<Regex> = Lazy::new(|| Regex::new("1").unwrap());
|
||||||
static ref ONE: Regex = Regex::new("1").unwrap();
|
static ZERO: Lazy<Regex> = Lazy::new(|| Regex::new("0").unwrap());
|
||||||
static ref ZERO: Regex = Regex::new("0").unwrap();
|
static SPACE: Lazy<Regex> = Lazy::new(|| Regex::new(" ").unwrap());
|
||||||
static ref SPACE: Regex = Regex::new(" ").unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constructs a BitArray from a String like the one returned from BitArray.toString()
|
* Constructs a BitArray from a String like the one returned from BitArray.toString()
|
||||||
|
|||||||
@@ -31,11 +31,9 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use crate::Exceptions;
|
use crate::Exceptions;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
lazy_static! {
|
static TWO_DIGIT_DATA_LENGTH: Lazy<HashMap<String, DataLength>> = Lazy::new(|| {
|
||||||
|
|
||||||
static ref TWO_DIGIT_DATA_LENGTH : HashMap<String,DataLength> = {
|
|
||||||
let mut hm = HashMap::new();
|
let mut hm = HashMap::new();
|
||||||
hm.insert("00".to_owned(), DataLength::fixed(18));
|
hm.insert("00".to_owned(), DataLength::fixed(18));
|
||||||
hm.insert("01".to_owned(), DataLength::fixed(14));
|
hm.insert("01".to_owned(), DataLength::fixed(14));
|
||||||
@@ -57,10 +55,9 @@ lazy_static! {
|
|||||||
hm.insert(i.to_string(), DataLength::variable(30));
|
hm.insert(i.to_string(), DataLength::variable(30));
|
||||||
}
|
}
|
||||||
hm
|
hm
|
||||||
};
|
});
|
||||||
|
|
||||||
static ref THREE_DIGIT_DATA_LENGTH : HashMap<String,DataLength>=
|
static THREE_DIGIT_DATA_LENGTH: Lazy<HashMap<String, DataLength>> = Lazy::new(|| {
|
||||||
{
|
|
||||||
let mut hm = HashMap::new();
|
let mut hm = HashMap::new();
|
||||||
hm.insert("240".to_owned(), DataLength::variable(30));
|
hm.insert("240".to_owned(), DataLength::variable(30));
|
||||||
hm.insert("241".to_owned(), DataLength::variable(30));
|
hm.insert("241".to_owned(), DataLength::variable(30));
|
||||||
@@ -87,9 +84,9 @@ lazy_static! {
|
|||||||
hm.insert("426".to_owned(), DataLength::fixed(3));
|
hm.insert("426".to_owned(), DataLength::fixed(3));
|
||||||
|
|
||||||
hm
|
hm
|
||||||
};
|
});
|
||||||
|
|
||||||
static ref THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH:HashMap<String,DataLength> = {
|
static THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH: Lazy<HashMap<String, DataLength>> = Lazy::new(|| {
|
||||||
let mut hm = HashMap::new();
|
let mut hm = HashMap::new();
|
||||||
for i in 310..=316 {
|
for i in 310..=316 {
|
||||||
// for (int i = 310; i <= 316; i++) {
|
// for (int i = 310; i <= 316; i++) {
|
||||||
@@ -114,9 +111,9 @@ lazy_static! {
|
|||||||
hm.insert("703".to_owned(), DataLength::variable(30));
|
hm.insert("703".to_owned(), DataLength::variable(30));
|
||||||
|
|
||||||
hm
|
hm
|
||||||
};
|
});
|
||||||
|
|
||||||
static ref FOUR_DIGIT_DATA_LENGTH : HashMap<String,DataLength>={
|
static FOUR_DIGIT_DATA_LENGTH: Lazy<HashMap<String, DataLength>> = Lazy::new(|| {
|
||||||
let mut hm = HashMap::new();
|
let mut hm = HashMap::new();
|
||||||
hm.insert("7001".to_owned(), DataLength::fixed(13));
|
hm.insert("7001".to_owned(), DataLength::fixed(13));
|
||||||
hm.insert("7002".to_owned(), DataLength::variable(30));
|
hm.insert("7002".to_owned(), DataLength::variable(30));
|
||||||
@@ -138,8 +135,7 @@ lazy_static! {
|
|||||||
hm.insert("8200".to_owned(), DataLength::variable(70));
|
hm.insert("8200".to_owned(), DataLength::variable(70));
|
||||||
|
|
||||||
hm
|
hm
|
||||||
};
|
});
|
||||||
}
|
|
||||||
|
|
||||||
pub fn parseFieldsInGeneralPurpose(rawInformation: &str) -> Result<String, Exceptions> {
|
pub fn parseFieldsInGeneralPurpose(rawInformation: &str) -> Result<String, Exceptions> {
|
||||||
if rawInformation.is_empty() {
|
if rawInformation.is_empty() {
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ use crate::{
|
|||||||
RXingResultMetadataType, RXingResultMetadataValue, Reader,
|
RXingResultMetadataType, RXingResultMetadataValue, Reader,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use super::{bit_array_builder, decoders::abstract_expanded_decoder, ExpandedPair, ExpandedRow};
|
use super::{bit_array_builder, decoders::abstract_expanded_decoder, ExpandedPair, ExpandedRow};
|
||||||
|
|
||||||
const FINDER_PAT_A: u32 = 0;
|
const FINDER_PAT_A: u32 = 0;
|
||||||
@@ -49,9 +51,8 @@ const FINDER_PAT_D: u32 = 3;
|
|||||||
const FINDER_PAT_E: u32 = 4;
|
const FINDER_PAT_E: u32 = 4;
|
||||||
const FINDER_PAT_F: u32 = 5;
|
const FINDER_PAT_F: u32 = 5;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
static FINDER_PATTERN_SEQUENCES: Lazy<Vec<Vec<u32>>> = Lazy::new(|| {
|
||||||
lazy_static! {
|
vec![
|
||||||
static ref FINDER_PATTERN_SEQUENCES: Vec<Vec<u32>> = vec![
|
|
||||||
vec![FINDER_PAT_A, FINDER_PAT_A],
|
vec![FINDER_PAT_A, FINDER_PAT_A],
|
||||||
vec![FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B],
|
vec![FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B],
|
||||||
vec![FINDER_PAT_A, FINDER_PAT_C, FINDER_PAT_B, FINDER_PAT_D],
|
vec![FINDER_PAT_A, FINDER_PAT_C, FINDER_PAT_B, FINDER_PAT_D],
|
||||||
@@ -60,7 +61,7 @@ lazy_static! {
|
|||||||
FINDER_PAT_E,
|
FINDER_PAT_E,
|
||||||
FINDER_PAT_B,
|
FINDER_PAT_B,
|
||||||
FINDER_PAT_D,
|
FINDER_PAT_D,
|
||||||
FINDER_PAT_C
|
FINDER_PAT_C,
|
||||||
],
|
],
|
||||||
vec![
|
vec![
|
||||||
FINDER_PAT_A,
|
FINDER_PAT_A,
|
||||||
@@ -68,7 +69,7 @@ lazy_static! {
|
|||||||
FINDER_PAT_B,
|
FINDER_PAT_B,
|
||||||
FINDER_PAT_D,
|
FINDER_PAT_D,
|
||||||
FINDER_PAT_D,
|
FINDER_PAT_D,
|
||||||
FINDER_PAT_F
|
FINDER_PAT_F,
|
||||||
],
|
],
|
||||||
vec![
|
vec![
|
||||||
FINDER_PAT_A,
|
FINDER_PAT_A,
|
||||||
@@ -77,7 +78,7 @@ lazy_static! {
|
|||||||
FINDER_PAT_D,
|
FINDER_PAT_D,
|
||||||
FINDER_PAT_E,
|
FINDER_PAT_E,
|
||||||
FINDER_PAT_F,
|
FINDER_PAT_F,
|
||||||
FINDER_PAT_F
|
FINDER_PAT_F,
|
||||||
],
|
],
|
||||||
vec![
|
vec![
|
||||||
FINDER_PAT_A,
|
FINDER_PAT_A,
|
||||||
@@ -87,7 +88,7 @@ lazy_static! {
|
|||||||
FINDER_PAT_C,
|
FINDER_PAT_C,
|
||||||
FINDER_PAT_C,
|
FINDER_PAT_C,
|
||||||
FINDER_PAT_D,
|
FINDER_PAT_D,
|
||||||
FINDER_PAT_D
|
FINDER_PAT_D,
|
||||||
],
|
],
|
||||||
vec![
|
vec![
|
||||||
FINDER_PAT_A,
|
FINDER_PAT_A,
|
||||||
@@ -98,7 +99,7 @@ lazy_static! {
|
|||||||
FINDER_PAT_C,
|
FINDER_PAT_C,
|
||||||
FINDER_PAT_D,
|
FINDER_PAT_D,
|
||||||
FINDER_PAT_E,
|
FINDER_PAT_E,
|
||||||
FINDER_PAT_E
|
FINDER_PAT_E,
|
||||||
],
|
],
|
||||||
vec![
|
vec![
|
||||||
FINDER_PAT_A,
|
FINDER_PAT_A,
|
||||||
@@ -110,7 +111,7 @@ lazy_static! {
|
|||||||
FINDER_PAT_D,
|
FINDER_PAT_D,
|
||||||
FINDER_PAT_E,
|
FINDER_PAT_E,
|
||||||
FINDER_PAT_F,
|
FINDER_PAT_F,
|
||||||
FINDER_PAT_F
|
FINDER_PAT_F,
|
||||||
],
|
],
|
||||||
vec![
|
vec![
|
||||||
FINDER_PAT_A,
|
FINDER_PAT_A,
|
||||||
@@ -123,10 +124,10 @@ lazy_static! {
|
|||||||
FINDER_PAT_E,
|
FINDER_PAT_E,
|
||||||
FINDER_PAT_E,
|
FINDER_PAT_E,
|
||||||
FINDER_PAT_F,
|
FINDER_PAT_F,
|
||||||
FINDER_PAT_F
|
FINDER_PAT_F,
|
||||||
],
|
],
|
||||||
];
|
]
|
||||||
}
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||||
|
|||||||
@@ -21,14 +21,12 @@ use crate::{
|
|||||||
|
|
||||||
use super::{one_d_reader, EANManufacturerOrgSupport, OneDReader, UPCEANExtensionSupport};
|
use super::{one_d_reader, EANManufacturerOrgSupport, OneDReader, UPCEANExtensionSupport};
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
lazy_static! {
|
pub static EAN_MANUFACTURER_SUPPORT: Lazy<EANManufacturerOrgSupport> =
|
||||||
pub static ref EAN_MANUFACTURER_SUPPORT: EANManufacturerOrgSupport =
|
Lazy::new(|| EANManufacturerOrgSupport::default());
|
||||||
EANManufacturerOrgSupport::default();
|
pub static UPC_EAN_EXTENSION_SUPPORT: Lazy<UPCEANExtensionSupport> =
|
||||||
pub static ref UPC_EAN_EXTENSION_SUPPORT: UPCEANExtensionSupport =
|
Lazy::new(|| UPCEANExtensionSupport::default());
|
||||||
UPCEANExtensionSupport::default();
|
|
||||||
}
|
|
||||||
|
|
||||||
// These two values are critical for determining how permissive the decoding will be.
|
// These two values are critical for determining how permissive the decoding will be.
|
||||||
// We've arrived at these values through a lot of trial and error. Setting them any higher
|
// We've arrived at these values through a lot of trial and error. Setting them any higher
|
||||||
|
|||||||
@@ -80,14 +80,13 @@ const MIXED_CHARS: [char; 25] = [
|
|||||||
'$', '/', '+', '%', '*', '=', '^',
|
'$', '/', '+', '%', '*', '=', '^',
|
||||||
];
|
];
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
lazy_static! {
|
|
||||||
/**
|
/**
|
||||||
* Table containing values for the exponent of 900.
|
* Table containing values for the exponent of 900.
|
||||||
* This is used in the numeric compaction decode algorithm.
|
* This is used in the numeric compaction decode algorithm.
|
||||||
*/
|
*/
|
||||||
static ref EXP900 : Vec<BigUint> = {
|
static EXP900: Lazy<Vec<BigUint>> = Lazy::new(|| {
|
||||||
const EXP_LEN: usize = 16;
|
const EXP_LEN: usize = 16;
|
||||||
let mut exp900 = Vec::with_capacity(EXP_LEN); //[0;16];
|
let mut exp900 = Vec::with_capacity(EXP_LEN); //[0;16];
|
||||||
exp900.push(ToBigUint::to_biguint(&1).unwrap());
|
exp900.push(ToBigUint::to_biguint(&1).unwrap());
|
||||||
@@ -102,8 +101,7 @@ lazy_static! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exp900
|
exp900
|
||||||
};
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Table containing values for the exponent of 900.
|
// * Table containing values for the exponent of 900.
|
||||||
|
|||||||
@@ -23,12 +23,10 @@ use crate::{
|
|||||||
|
|
||||||
use super::ModulusPoly;
|
use super::ModulusPoly;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
lazy_static! {
|
|
||||||
// static ref PDF417_GF : Rc<&ModulusGF> = Rc::new(&ModulusGF::new(NUMBER_OF_CODEWORDS, 3));
|
// static ref PDF417_GF : Rc<&ModulusGF> = Rc::new(&ModulusGF::new(NUMBER_OF_CODEWORDS, 3));
|
||||||
static ref FLD_INTERIOR : ModulusGF = ModulusGF::new(NUMBER_OF_CODEWORDS, 3);
|
static FLD_INTERIOR: Lazy<ModulusGF> = Lazy::new(|| ModulusGF::new(NUMBER_OF_CODEWORDS, 3));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>PDF417 error correction implementation.</p>
|
* <p>PDF417 error correction implementation.</p>
|
||||||
|
|||||||
@@ -22,107 +22,93 @@
|
|||||||
* PDF417 error correction code following the algorithm described in ISO/IEC 15438:2001(E) in
|
* PDF417 error correction code following the algorithm described in ISO/IEC 15438:2001(E) in
|
||||||
* chapter 4.10.
|
* chapter 4.10.
|
||||||
*/
|
*/
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use crate::Exceptions;
|
use crate::Exceptions;
|
||||||
|
|
||||||
lazy_static! {
|
|
||||||
/**
|
/**
|
||||||
* Tables of coefficients for calculating error correction words
|
* Tables of coefficients for calculating error correction words
|
||||||
* (see annex F, ISO/IEC 15438:2001(E))
|
* (see annex F, ISO/IEC 15438:2001(E))
|
||||||
*/
|
*/
|
||||||
static ref EC_COEFFICIENTS : [Vec<u32>;9] = [
|
static EC_COEFFICIENTS: Lazy<[Vec<u32>; 9]> = Lazy::new(|| {
|
||||||
|
[
|
||||||
vec![27, 917],
|
vec![27, 917],
|
||||||
vec![522, 568, 723, 809],
|
vec![522, 568, 723, 809],
|
||||||
vec![237, 308, 436, 284, 646, 653, 428, 379],
|
vec![237, 308, 436, 284, 646, 653, 428, 379],
|
||||||
vec![274, 562, 232, 755, 599, 524, 801, 132, 295, 116, 442, 428, 295,
|
vec![
|
||||||
42, 176, 65],
|
274, 562, 232, 755, 599, 524, 801, 132, 295, 116, 442, 428, 295, 42, 176, 65,
|
||||||
vec![361, 575, 922, 525, 176, 586, 640, 321, 536, 742, 677, 742, 687,
|
],
|
||||||
284, 193, 517, 273, 494, 263, 147, 593, 800, 571, 320, 803,
|
vec![
|
||||||
133, 231, 390, 685, 330, 63, 410],
|
361, 575, 922, 525, 176, 586, 640, 321, 536, 742, 677, 742, 687, 284, 193, 517, 273,
|
||||||
vec![539, 422, 6, 93, 862, 771, 453, 106, 610, 287, 107, 505, 733,
|
494, 263, 147, 593, 800, 571, 320, 803, 133, 231, 390, 685, 330, 63, 410,
|
||||||
877, 381, 612, 723, 476, 462, 172, 430, 609, 858, 822, 543,
|
],
|
||||||
376, 511, 400, 672, 762, 283, 184, 440, 35, 519, 31, 460,
|
vec![
|
||||||
594, 225, 535, 517, 352, 605, 158, 651, 201, 488, 502, 648,
|
539, 422, 6, 93, 862, 771, 453, 106, 610, 287, 107, 505, 733, 877, 381, 612, 723, 476,
|
||||||
733, 717, 83, 404, 97, 280, 771, 840, 629, 4, 381, 843,
|
462, 172, 430, 609, 858, 822, 543, 376, 511, 400, 672, 762, 283, 184, 440, 35, 519, 31,
|
||||||
623, 264, 543],
|
460, 594, 225, 535, 517, 352, 605, 158, 651, 201, 488, 502, 648, 733, 717, 83, 404, 97,
|
||||||
vec![521, 310, 864, 547, 858, 580, 296, 379, 53, 779, 897, 444, 400,
|
280, 771, 840, 629, 4, 381, 843, 623, 264, 543,
|
||||||
925, 749, 415, 822, 93, 217, 208, 928, 244, 583, 620, 246,
|
],
|
||||||
148, 447, 631, 292, 908, 490, 704, 516, 258, 457, 907, 594,
|
vec![
|
||||||
723, 674, 292, 272, 96, 684, 432, 686, 606, 860, 569, 193,
|
521, 310, 864, 547, 858, 580, 296, 379, 53, 779, 897, 444, 400, 925, 749, 415, 822, 93,
|
||||||
219, 129, 186, 236, 287, 192, 775, 278, 173, 40, 379, 712,
|
217, 208, 928, 244, 583, 620, 246, 148, 447, 631, 292, 908, 490, 704, 516, 258, 457,
|
||||||
463, 646, 776, 171, 491, 297, 763, 156, 732, 95, 270, 447,
|
907, 594, 723, 674, 292, 272, 96, 684, 432, 686, 606, 860, 569, 193, 219, 129, 186,
|
||||||
90, 507, 48, 228, 821, 808, 898, 784, 663, 627, 378, 382,
|
236, 287, 192, 775, 278, 173, 40, 379, 712, 463, 646, 776, 171, 491, 297, 763, 156,
|
||||||
262, 380, 602, 754, 336, 89, 614, 87, 432, 670, 616, 157,
|
732, 95, 270, 447, 90, 507, 48, 228, 821, 808, 898, 784, 663, 627, 378, 382, 262, 380,
|
||||||
374, 242, 726, 600, 269, 375, 898, 845, 454, 354, 130, 814,
|
602, 754, 336, 89, 614, 87, 432, 670, 616, 157, 374, 242, 726, 600, 269, 375, 898, 845,
|
||||||
587, 804, 34, 211, 330, 539, 297, 827, 865, 37, 517, 834,
|
454, 354, 130, 814, 587, 804, 34, 211, 330, 539, 297, 827, 865, 37, 517, 834, 315, 550,
|
||||||
315, 550, 86, 801, 4, 108, 539],
|
86, 801, 4, 108, 539,
|
||||||
vec![524, 894, 75, 766, 882, 857, 74, 204, 82, 586, 708, 250, 905,
|
],
|
||||||
786, 138, 720, 858, 194, 311, 913, 275, 190, 375, 850, 438,
|
vec![
|
||||||
733, 194, 280, 201, 280, 828, 757, 710, 814, 919, 89, 68,
|
524, 894, 75, 766, 882, 857, 74, 204, 82, 586, 708, 250, 905, 786, 138, 720, 858, 194,
|
||||||
569, 11, 204, 796, 605, 540, 913, 801, 700, 799, 137, 439,
|
311, 913, 275, 190, 375, 850, 438, 733, 194, 280, 201, 280, 828, 757, 710, 814, 919,
|
||||||
418, 592, 668, 353, 859, 370, 694, 325, 240, 216, 257, 284,
|
89, 68, 569, 11, 204, 796, 605, 540, 913, 801, 700, 799, 137, 439, 418, 592, 668, 353,
|
||||||
549, 209, 884, 315, 70, 329, 793, 490, 274, 877, 162, 749,
|
859, 370, 694, 325, 240, 216, 257, 284, 549, 209, 884, 315, 70, 329, 793, 490, 274,
|
||||||
812, 684, 461, 334, 376, 849, 521, 307, 291, 803, 712, 19,
|
877, 162, 749, 812, 684, 461, 334, 376, 849, 521, 307, 291, 803, 712, 19, 358, 399,
|
||||||
358, 399, 908, 103, 511, 51, 8, 517, 225, 289, 470, 637,
|
908, 103, 511, 51, 8, 517, 225, 289, 470, 637, 731, 66, 255, 917, 269, 463, 830, 730,
|
||||||
731, 66, 255, 917, 269, 463, 830, 730, 433, 848, 585, 136,
|
433, 848, 585, 136, 538, 906, 90, 2, 290, 743, 199, 655, 903, 329, 49, 802, 580, 355,
|
||||||
538, 906, 90, 2, 290, 743, 199, 655, 903, 329, 49, 802,
|
588, 188, 462, 10, 134, 628, 320, 479, 130, 739, 71, 263, 318, 374, 601, 192, 605, 142,
|
||||||
580, 355, 588, 188, 462, 10, 134, 628, 320, 479, 130, 739,
|
673, 687, 234, 722, 384, 177, 752, 607, 640, 455, 193, 689, 707, 805, 641, 48, 60, 732,
|
||||||
71, 263, 318, 374, 601, 192, 605, 142, 673, 687, 234, 722,
|
621, 895, 544, 261, 852, 655, 309, 697, 755, 756, 60, 231, 773, 434, 421, 726, 528,
|
||||||
384, 177, 752, 607, 640, 455, 193, 689, 707, 805, 641, 48,
|
503, 118, 49, 795, 32, 144, 500, 238, 836, 394, 280, 566, 319, 9, 647, 550, 73, 914,
|
||||||
60, 732, 621, 895, 544, 261, 852, 655, 309, 697, 755, 756,
|
342, 126, 32, 681, 331, 792, 620, 60, 609, 441, 180, 791, 893, 754, 605, 383, 228, 749,
|
||||||
60, 231, 773, 434, 421, 726, 528, 503, 118, 49, 795, 32,
|
760, 213, 54, 297, 134, 54, 834, 299, 922, 191, 910, 532, 609, 829, 189, 20, 167, 29,
|
||||||
144, 500, 238, 836, 394, 280, 566, 319, 9, 647, 550, 73,
|
872, 449, 83, 402, 41, 656, 505, 579, 481, 173, 404, 251, 688, 95, 497, 555, 642, 543,
|
||||||
914, 342, 126, 32, 681, 331, 792, 620, 60, 609, 441, 180,
|
307, 159, 924, 558, 648, 55, 497, 10,
|
||||||
791, 893, 754, 605, 383, 228, 749, 760, 213, 54, 297, 134,
|
],
|
||||||
54, 834, 299, 922, 191, 910, 532, 609, 829, 189, 20, 167,
|
vec![
|
||||||
29, 872, 449, 83, 402, 41, 656, 505, 579, 481, 173, 404,
|
352, 77, 373, 504, 35, 599, 428, 207, 409, 574, 118, 498, 285, 380, 350, 492, 197, 265,
|
||||||
251, 688, 95, 497, 555, 642, 543, 307, 159, 924, 558, 648,
|
920, 155, 914, 299, 229, 643, 294, 871, 306, 88, 87, 193, 352, 781, 846, 75, 327, 520,
|
||||||
55, 497, 10],
|
435, 543, 203, 666, 249, 346, 781, 621, 640, 268, 794, 534, 539, 781, 408, 390, 644,
|
||||||
vec![352, 77, 373, 504, 35, 599, 428, 207, 409, 574, 118, 498, 285,
|
102, 476, 499, 290, 632, 545, 37, 858, 916, 552, 41, 542, 289, 122, 272, 383, 800, 485,
|
||||||
380, 350, 492, 197, 265, 920, 155, 914, 299, 229, 643, 294,
|
98, 752, 472, 761, 107, 784, 860, 658, 741, 290, 204, 681, 407, 855, 85, 99, 62, 482,
|
||||||
871, 306, 88, 87, 193, 352, 781, 846, 75, 327, 520, 435,
|
180, 20, 297, 451, 593, 913, 142, 808, 684, 287, 536, 561, 76, 653, 899, 729, 567, 744,
|
||||||
543, 203, 666, 249, 346, 781, 621, 640, 268, 794, 534, 539,
|
390, 513, 192, 516, 258, 240, 518, 794, 395, 768, 848, 51, 610, 384, 168, 190, 826,
|
||||||
781, 408, 390, 644, 102, 476, 499, 290, 632, 545, 37, 858,
|
328, 596, 786, 303, 570, 381, 415, 641, 156, 237, 151, 429, 531, 207, 676, 710, 89,
|
||||||
916, 552, 41, 542, 289, 122, 272, 383, 800, 485, 98, 752,
|
168, 304, 402, 40, 708, 575, 162, 864, 229, 65, 861, 841, 512, 164, 477, 221, 92, 358,
|
||||||
472, 761, 107, 784, 860, 658, 741, 290, 204, 681, 407, 855,
|
785, 288, 357, 850, 836, 827, 736, 707, 94, 8, 494, 114, 521, 2, 499, 851, 543, 152,
|
||||||
85, 99, 62, 482, 180, 20, 297, 451, 593, 913, 142, 808,
|
729, 771, 95, 248, 361, 578, 323, 856, 797, 289, 51, 684, 466, 533, 820, 669, 45, 902,
|
||||||
684, 287, 536, 561, 76, 653, 899, 729, 567, 744, 390, 513,
|
452, 167, 342, 244, 173, 35, 463, 651, 51, 699, 591, 452, 578, 37, 124, 298, 332, 552,
|
||||||
192, 516, 258, 240, 518, 794, 395, 768, 848, 51, 610, 384,
|
43, 427, 119, 662, 777, 475, 850, 764, 364, 578, 911, 283, 711, 472, 420, 245, 288,
|
||||||
168, 190, 826, 328, 596, 786, 303, 570, 381, 415, 641, 156,
|
594, 394, 511, 327, 589, 777, 699, 688, 43, 408, 842, 383, 721, 521, 560, 644, 714,
|
||||||
237, 151, 429, 531, 207, 676, 710, 89, 168, 304, 402, 40,
|
559, 62, 145, 873, 663, 713, 159, 672, 729, 624, 59, 193, 417, 158, 209, 563, 564, 343,
|
||||||
708, 575, 162, 864, 229, 65, 861, 841, 512, 164, 477, 221,
|
693, 109, 608, 563, 365, 181, 772, 677, 310, 248, 353, 708, 410, 579, 870, 617, 841,
|
||||||
92, 358, 785, 288, 357, 850, 836, 827, 736, 707, 94, 8,
|
632, 860, 289, 536, 35, 777, 618, 586, 424, 833, 77, 597, 346, 269, 757, 632, 695, 751,
|
||||||
494, 114, 521, 2, 499, 851, 543, 152, 729, 771, 95, 248,
|
331, 247, 184, 45, 787, 680, 18, 66, 407, 369, 54, 492, 228, 613, 830, 922, 437, 519,
|
||||||
361, 578, 323, 856, 797, 289, 51, 684, 466, 533, 820, 669,
|
644, 905, 789, 420, 305, 441, 207, 300, 892, 827, 141, 537, 381, 662, 513, 56, 252,
|
||||||
45, 902, 452, 167, 342, 244, 173, 35, 463, 651, 51, 699,
|
341, 242, 797, 838, 837, 720, 224, 307, 631, 61, 87, 560, 310, 756, 665, 397, 808, 851,
|
||||||
591, 452, 578, 37, 124, 298, 332, 552, 43, 427, 119, 662,
|
309, 473, 795, 378, 31, 647, 915, 459, 806, 590, 731, 425, 216, 548, 249, 321, 881,
|
||||||
777, 475, 850, 764, 364, 578, 911, 283, 711, 472, 420, 245,
|
699, 535, 673, 782, 210, 815, 905, 303, 843, 922, 281, 73, 469, 791, 660, 162, 498,
|
||||||
288, 594, 394, 511, 327, 589, 777, 699, 688, 43, 408, 842,
|
308, 155, 422, 907, 817, 187, 62, 16, 425, 535, 336, 286, 437, 375, 273, 610, 296, 183,
|
||||||
383, 721, 521, 560, 644, 714, 559, 62, 145, 873, 663, 713,
|
923, 116, 667, 751, 353, 62, 366, 691, 379, 687, 842, 37, 357, 720, 742, 330, 5, 39,
|
||||||
159, 672, 729, 624, 59, 193, 417, 158, 209, 563, 564, 343,
|
923, 311, 424, 242, 749, 321, 54, 669, 316, 342, 299, 534, 105, 667, 488, 640, 672,
|
||||||
693, 109, 608, 563, 365, 181, 772, 677, 310, 248, 353, 708,
|
576, 540, 316, 486, 721, 610, 46, 656, 447, 171, 616, 464, 190, 531, 297, 321, 762,
|
||||||
410, 579, 870, 617, 841, 632, 860, 289, 536, 35, 777, 618,
|
752, 533, 175, 134, 14, 381, 433, 717, 45, 111, 20, 596, 284, 736, 138, 646, 411, 877,
|
||||||
586, 424, 833, 77, 597, 346, 269, 757, 632, 695, 751, 331,
|
669, 141, 919, 45, 780, 407, 164, 332, 899, 165, 726, 600, 325, 498, 655, 357, 752,
|
||||||
247, 184, 45, 787, 680, 18, 66, 407, 369, 54, 492, 228,
|
768, 223, 849, 647, 63, 310, 863, 251, 366, 304, 282, 738, 675, 410, 389, 244, 31, 121,
|
||||||
613, 830, 922, 437, 519, 644, 905, 789, 420, 305, 441, 207,
|
303, 263,
|
||||||
300, 892, 827, 141, 537, 381, 662, 513, 56, 252, 341, 242,
|
],
|
||||||
797, 838, 837, 720, 224, 307, 631, 61, 87, 560, 310, 756,
|
]
|
||||||
665, 397, 808, 851, 309, 473, 795, 378, 31, 647, 915, 459,
|
});
|
||||||
806, 590, 731, 425, 216, 548, 249, 321, 881, 699, 535, 673,
|
|
||||||
782, 210, 815, 905, 303, 843, 922, 281, 73, 469, 791, 660,
|
|
||||||
162, 498, 308, 155, 422, 907, 817, 187, 62, 16, 425, 535,
|
|
||||||
336, 286, 437, 375, 273, 610, 296, 183, 923, 116, 667, 751,
|
|
||||||
353, 62, 366, 691, 379, 687, 842, 37, 357, 720, 742, 330,
|
|
||||||
5, 39, 923, 311, 424, 242, 749, 321, 54, 669, 316, 342,
|
|
||||||
299, 534, 105, 667, 488, 640, 672, 576, 540, 316, 486, 721,
|
|
||||||
610, 46, 656, 447, 171, 616, 464, 190, 531, 297, 321, 762,
|
|
||||||
752, 533, 175, 134, 14, 381, 433, 717, 45, 111, 20, 596,
|
|
||||||
284, 736, 138, 646, 411, 877, 669, 141, 919, 45, 780, 407,
|
|
||||||
164, 332, 899, 165, 726, 600, 325, 498, 655, 357, 752, 768,
|
|
||||||
223, 849, 647, 63, 310, 863, 251, 366, 304, 282, 738, 675,
|
|
||||||
410, 389, 244, 31, 121, 303, 263]];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines the number of error correction codewords for a specified error correction
|
* Determines the number of error correction codewords for a specified error correction
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ use std::{collections::HashMap, rc::Rc};
|
|||||||
*
|
*
|
||||||
* @author Sean Owen
|
* @author Sean Owen
|
||||||
*/
|
*/
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::{
|
common::{
|
||||||
@@ -34,10 +34,12 @@ use crate::{
|
|||||||
|
|
||||||
use super::{decoded_bit_stream_parser, BitMatrixParser, DataBlock, QRCodeDecoderMetaData};
|
use super::{decoded_bit_stream_parser, BitMatrixParser, DataBlock, QRCodeDecoderMetaData};
|
||||||
|
|
||||||
lazy_static! {
|
|
||||||
//rsDecoder = new ReedSolomonDecoder(GenericGF.QR_CODE_FIELD_256);
|
//rsDecoder = new ReedSolomonDecoder(GenericGF.QR_CODE_FIELD_256);
|
||||||
static ref RS_DECODER : ReedSolomonDecoder = ReedSolomonDecoder::new(get_predefined_genericgf(PredefinedGenericGF::QrCodeField256));
|
static RS_DECODER: Lazy<ReedSolomonDecoder> = Lazy::new(|| {
|
||||||
}
|
ReedSolomonDecoder::new(get_predefined_genericgf(
|
||||||
|
PredefinedGenericGF::QrCodeField256,
|
||||||
|
))
|
||||||
|
});
|
||||||
|
|
||||||
pub fn decode_bool_array(image: &Vec<Vec<bool>>) -> Result<DecoderRXingResult, Exceptions> {
|
pub fn decode_bool_array(image: &Vec<Vec<bool>>) -> Result<DecoderRXingResult, Exceptions> {
|
||||||
decode_bool_array_with_hints(image, &HashMap::new())
|
decode_bool_array_with_hints(image, &HashMap::new())
|
||||||
|
|||||||
@@ -20,13 +20,11 @@ use crate::{common::BitMatrix, Exceptions};
|
|||||||
|
|
||||||
use super::{ErrorCorrectionLevel, FormatInformation};
|
use super::{ErrorCorrectionLevel, FormatInformation};
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
pub type VersionRef = &'static Version;
|
pub type VersionRef = &'static Version;
|
||||||
|
|
||||||
lazy_static! {
|
static VERSIONS: Lazy<Vec<Version>> = Lazy::new(|| Version::buildVersions());
|
||||||
static ref VERSIONS: Vec<Version> = Version::buildVersions();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See ISO 18004:2006 Annex D.
|
* See ISO 18004:2006 Annex D.
|
||||||
|
|||||||
@@ -25,14 +25,12 @@ use crate::{
|
|||||||
EncodeHintType, EncodeHintValue,
|
EncodeHintType, EncodeHintValue,
|
||||||
};
|
};
|
||||||
use encoding::EncodingRef;
|
use encoding::EncodingRef;
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use super::QRCode;
|
use super::QRCode;
|
||||||
|
|
||||||
lazy_static! {
|
static SHIFT_JIS_CHARSET: Lazy<EncodingRef> =
|
||||||
static ref SHIFT_JIS_CHARSET: EncodingRef =
|
Lazy::new(|| encoding::label::encoding_from_whatwg_label("SJIS").unwrap());
|
||||||
encoding::label::encoding_from_whatwg_label("SJIS").unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author satorux@google.com (Satoru Takabayashi) - creator
|
* @author satorux@google.com (Satoru Takabayashi) - creator
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use encoding::EncodingRef;
|
use encoding::EncodingRef;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -35,10 +35,8 @@ use crate::{
|
|||||||
|
|
||||||
use super::{mask_util, matrix_util, BlockPair, ByteMatrix, MinimalEncoder, QRCode};
|
use super::{mask_util, matrix_util, BlockPair, ByteMatrix, MinimalEncoder, QRCode};
|
||||||
|
|
||||||
lazy_static! {
|
static SHIFT_JIS_CHARSET: Lazy<EncodingRef> =
|
||||||
static ref SHIFT_JIS_CHARSET: EncodingRef =
|
Lazy::new(|| encoding::label::encoding_from_whatwg_label("SJIS").unwrap());
|
||||||
encoding::label::encoding_from_whatwg_label("SJIS").unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
// The original table is defined in the table 5 of JISX0510:2004 (p.19).
|
// The original table is defined in the table 5 of JISX0510:2004 (p.19).
|
||||||
const ALPHANUMERIC_TABLE: [i8; 96] = [
|
const ALPHANUMERIC_TABLE: [i8; 96] = [
|
||||||
|
|||||||
Reference in New Issue
Block a user