Build-Fix: KitColor statt RGBColor (Namenskonflikt mit QuickDraw), öffentlicher JerseySuggestion-Init, k-means vereinfacht, CGFloat→Double; Warnungen (NSLock in async, Captures)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012bGzgsxrmbBhDzeMV2L57D
This commit is contained in:
Lichtkasten DevandClaude Opus 5.5 committed 2026-11-04 01:16:47 +00:00
1 parent 9dcef7bd88
commit 3aa5bdef0e
6 files changed
+72 -40

No files matched your search

@@ -1,12 +1,12 @@
import Foundation
/// Simple RGB color (0…1), Codable for settings.
public struct RGBColor: Codable, Hashable, Sendable {
public struct KitColor: Codable, Hashable, Sendable {
public var r: Double, g: Double, b: Double
public init(r: Double, g: Double, b: Double) { self.r = r; self.g = g; self.b = b }
/// Perceptual-ish distance (weighted RGB, "redmean"), 0 … ~1.
public func distance(to o: RGBColor) -> Double {
public func distance(to o: KitColor) -> Double {
let rm = (r + o.r) / 2
let dr = r - o.r, dg = g - o.g, db = b - o.b
return sqrt((2 + rm) * dr * dr + 4 * dg * dg + (3 - rm) * db * db) / 3
@@ -20,10 +20,10 @@ public struct JerseyTeam: Codable, Hashable, Identifiable, Sendable {
public var codeSetID: UUID?
/// Code = prefix + number, e.g. "w" + "10" → "w10"
public var prefix: String
public var shirtColor: RGBColor
public var shortsColor: RGBColor?
public var shirtColor: KitColor
public var shortsColor: KitColor?
public init(name: String, codeSetID: UUID? = nil, prefix: String, shirtColor: RGBColor, shortsColor: RGBColor? = nil) {
public init(name: String, codeSetID: UUID? = nil, prefix: String, shirtColor: KitColor, shortsColor: KitColor? = nil) {
self.name = name; self.codeSetID = codeSetID; self.prefix = prefix
self.shirtColor = shirtColor; self.shortsColor = shortsColor
}
@@ -44,6 +44,12 @@ public struct JerseySuggestion: Codable, Hashable, Identifiable, Sendable {
public var box: [Double] // x, y, w, h
/// Person size in the frame (main subject first)
public var personArea: Double
public init(number: Int, teamID: UUID?, code: String?, replacement: String?, confidence: Double,
regions: [JerseyRegion], box: [Double], personArea: Double) {
self.number = number; self.teamID = teamID; self.code = code; self.replacement = replacement
self.confidence = confidence; self.regions = regions; self.box = box; self.personArea = personArea
}
}
public enum JerseyLogic {
@@ -72,7 +78,7 @@ public enum JerseyLogic {
}
/// Team whose kit color is closest (shirt for shirt numbers, shorts or shirt for shorts numbers).
public static func matchTeam(color: RGBColor, region: JerseyRegion, teams: [JerseyTeam], threshold: Double = 0.30) -> JerseyTeam? {
public static func matchTeam(color: KitColor, region: JerseyRegion, teams: [JerseyTeam], threshold: Double = 0.30) -> JerseyTeam? {
var best: (JerseyTeam, Double)?
for t in teams {
var d = color.distance(to: t.shirtColor)