SPB Git

Repository Public

ScanDraft.swift 3.1 KB 82 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project          : SP ID & Card Vault7// File             : SPVault/Engines/SmartScan/ScanDraft.swift8// Module           : SPVault9// Repository       : https://git.spboucher.ai/sp-id-card-vault10// Project Website  : Not specified11// Created          : 2026-12-0212// Last Modified    : 2026-12-0213//14// Author           : Simon-Pierre Boucher15// Position         : Professor of Finance16// Institution      : Université du Québec en Outaouais (UQO)17// Organization     : SP Boucher18// Website          : https://spboucher.ai19// Git              : https://git.spboucher.ai20//21// Preferred Contact: contact@spboucher.ai22// Development      : dev@spboucher.ai23// Support          : support@spboucher.ai24// Security/Admin   : admin@spboucher.ai25//26// Copyright (c) 202627// Simon-Pierre Boucher28// All rights reserved where applicable. This file is governed by the29// applicable project license, copyright notices and relevant law.30// Existing third-party rights and notices remain unaffected.31//32// License          : None specified (no license file in this repository)33//34// Do not embed credentials, private keys, access tokens,35// certificates or confidential personal information.36//37// =============================================================================38// END OF SP BOUCHER SOURCE HEADER39// =============================================================================4041import CoreGraphics42import Foundation4344/// Metadata read from a card by local OCR. Every value is a proposal the owner45/// can correct; a field that could not be read with confidence stays `nil`46/// rather than being guessed. There is deliberately no security-code field.47struct CardSuggestion: Equatable, Sendable {48    var name: String?49    var issuer: String?50    var holderName: String?51    var number: String?52    var expiry: Date?53}5455/// Result of the scanner flow: processed photographs held in memory (never on56/// disk, never in Photos) plus the proposals, ready for the card editor.57struct ScanDraft: @unchecked Sendable {58    var kind: CardKind59    /// Perspective-corrected front, already cropped to the card.60    var front: CGImage61    /// Corrected back. For bank cards the security code has already been62    /// irreversibly blacked out in these pixels.63    var back: CGImage?64    var format: CardFormat65    var dominantColor: RGB66    var suggestion: CardSuggestion6768    /// Card record pre-filled from the proposals.69    func makeCard(reminderOffsets: [Int]) -> Card {70        var card = Card(name: suggestion.name ?? kind.title, kind: kind)71        card.issuer = suggestion.issuer ?? ""72        card.holderName = suggestion.holderName ?? ""73        card.number = suggestion.number ?? ""74        card.expiry = suggestion.expiry75        card.format = format76        card.dominantColor = dominantColor77        card.reminderOffsets = reminderOffsets78        card.hasBack = back != nil79        return card80    }81}82
Files main
Menu

Theme