mirror of
https://github.com/Aminark/legado-ios.git
synced 2026-10-20 19:21:22 +08:00
14 lines
451 B
Swift
14 lines
451 B
Swift
import Foundation
|
|
import Vision
|
|
|
|
public struct QRCodeDecoder: Sendable {
|
|
public init() {}
|
|
public func detect(in data: Data) throws -> [String] {
|
|
let request = VNDetectBarcodesRequest()
|
|
request.symbologies = [.qr]
|
|
try VNImageRequestHandler(data: data).perform([request])
|
|
var seen = Set<String>()
|
|
return (request.results ?? []).compactMap(\.payloadStringValue).filter { seen.insert($0).inserted }
|
|
}
|
|
}
|