Slide 45
Slide 45 text
γϯϘϧҐஔ/߹ܭͱύϦςΟ͕औΕΔ
@objc func captureResult(_ capture: ZXCapture!, result: ZXResult!) {
guard let _ = result else { return }
// ׂQRίʔυͷ߹ɺZXResult#resultMetadata ͷҎԼ2ͭΛ֬ೝͯ͠
// Ͳͷ෦ͷQRίʔυ͕ಡΈࠐ·Εͨͷ͔ఆ͢Δ͜ͱ͕Ͱ͖Δ
// - kResultMetadataTypeStructuredAppendSequence
// - kResultMetadataTypeStructuredAppendParity
guard let metaData = result.resultMetadata,
let sequenceValue = metaData[Int(kResultMetadataTypeStructuredAppendSequence.rawValue)] as? Int,
let parity = metaData[Int(kResultMetadataTypeStructuredAppendParity.rawValue)] as? Int
else { return }
// sequence: ಡΈऔͬͨQRίʔυͷ൪߸ 4bit + τʔλϧͷQRίʔυ 4bit
let bit = String(sequenceValue, radix: 2)
let pad = String(repeating: "0", count: (8 - bit.count))
let sequence = pad + bit
let current = Int(sequence.prefix(4), radix: 2)!
let total = Int(sequence.suffix(from: 4), radix: 2)!
…
}
@objc func captureResult(_ capture: ZXCapture!, result: ZXResult!) {
guard let _ = result else { return }
// ׂQRίʔυͷ߹ɺZXResult#resultMetadata ͷҎԼ2ͭΛ֬ೝͯ͠
// Ͳͷ෦ͷQRίʔυ͕ಡΈࠐ·Εͨͷ͔ఆ͢Δ͜ͱ͕Ͱ͖Δ
// - kResultMetadataTypeStructuredAppendSequence
// - kResultMetadataTypeStructuredAppendParity
guard let metaData = result.resultMetadata,
let sequenceValue = metaData[Int(kResultMetadataTypeStructuredAppendSequence.rawValue)] as? Int,
let parity = metaData[Int(kResultMetadataTypeStructuredAppendParity.rawValue)] as? Int
else { return }
// sequence: ಡΈऔͬͨQRίʔυͷ൪߸ 4bit + τʔλϧͷQRίʔυ 4bit
let bit = String(sequenceValue, radix: 2)
let pad = String(repeating: "0", count: (8 - bit.count))
let sequence = pad + bit
let current = Int(sequence.prefix(4), radix: 2)!
let total = Int(sequence.suffix(from: 4), radix: 2)!
…
}