Trikotnummern-Erkennung (Trikot + Hose, Vision on-device), Team über Trikotfarbe, Vorschläge mit Bestätigung im IPTC-Fenster (⌘J), Abzeichen + Filter
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012bGzgsxrmbBhDzeMV2L57D
This commit is contained in:
1 parent
5505fa1f37
commit
9dcef7bd88
11 files changed
+788
-3
No files matched your search
@@ -19,6 +19,7 @@ struct IPTCInfoWindow: View {
|
||||
var body: some View {
|
||||
HSplitView {
|
||||
VStack(spacing: 0) {
|
||||
suggestionBar
|
||||
ScrollView {
|
||||
PMMetadataForm(texts: $texts, columns: 1, dirty: dirty, codes: state.codes, fieldLists: state.settings.fieldLists,
|
||||
onEdit: { dirty.insert($0) }, extraAfterContent: AnyView(labelSection))
|
||||
@@ -84,13 +85,94 @@ struct IPTCInfoWindow: View {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Jersey suggestions
|
||||
|
||||
private var openSuggestions: [JerseySuggestion] { item.map { state.openSuggestions(for: $0.id) } ?? [] }
|
||||
|
||||
@ViewBuilder
|
||||
private var suggestionBar: some View {
|
||||
let open = openSuggestions
|
||||
if !open.isEmpty, let item {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
HStack {
|
||||
Image(systemName: "person.text.rectangle").foregroundStyle(Color.accentColor)
|
||||
Text("Erkannt:").bold()
|
||||
Spacer()
|
||||
if open.count > 1 {
|
||||
Button("Alle annehmen") { accept(open) }
|
||||
}
|
||||
Button("Neu erkennen") { state.recognizeJerseys([item], onlyNew: false) }
|
||||
.controlSize(.small)
|
||||
}
|
||||
ForEach(Array(open.enumerated()), id: \.element.id) { idx, s in
|
||||
HStack(spacing: 8) {
|
||||
Text(s.code ?? "#\(s.number)").font(.system(.body, design: .monospaced)).bold()
|
||||
Text(s.replacement ?? "–").lineLimit(1)
|
||||
Text(s.regions.map(\.rawValue).joined(separator: "+") + " · \(Int(s.confidence * 100)) %")
|
||||
.font(.caption).foregroundStyle(.secondary)
|
||||
Spacer()
|
||||
if idx == 0 {
|
||||
Button("Annehmen (⌘J)") { accept([s]) }
|
||||
.keyboardShortcut("j", modifiers: .command)
|
||||
.buttonStyle(.borderedProminent)
|
||||
} else {
|
||||
Button("Annehmen") { accept([s]) }
|
||||
}
|
||||
Button { state.dismissSuggestion(s, for: item.id) } label: { Image(systemName: "xmark") }
|
||||
.help("Falsch – verwerfen")
|
||||
}
|
||||
.padding(.vertical, 2)
|
||||
}
|
||||
}
|
||||
.padding(10)
|
||||
.background(Color.accentColor.opacity(0.10))
|
||||
Divider()
|
||||
}
|
||||
}
|
||||
|
||||
/// Fills caption (first line) and "Persons shown" in the form – saved with ⌘B / OK as usual.
|
||||
private func accept(_ s: [JerseySuggestion]) {
|
||||
guard let item else { return }
|
||||
let updated = state.applying(s, to: IPTCValues(texts: texts))
|
||||
let newTexts = updated.texts()
|
||||
for id in ["caption", "personInImage"] where (texts[id] ?? "") != (newTexts[id] ?? "") {
|
||||
texts[id] = newTexts[id] ?? ""
|
||||
dirty.insert(id)
|
||||
}
|
||||
state.markSuggestionsDone(s, for: item.id)
|
||||
}
|
||||
|
||||
/// Boxes around the recognized numbers on the preview.
|
||||
private func numberBoxes(in size: CGSize) -> some View {
|
||||
ZStack(alignment: .topLeading) {
|
||||
ForEach(openSuggestions) { s in
|
||||
if s.box.count == 4 {
|
||||
let r = CGRect(x: s.box[0] * size.width, y: s.box[1] * size.height,
|
||||
width: max(14, s.box[2] * size.width), height: max(14, s.box[3] * size.height))
|
||||
Rectangle().stroke(Color.yellow, lineWidth: 2)
|
||||
.frame(width: r.width, height: r.height)
|
||||
.overlay(alignment: .topLeading) {
|
||||
Text(s.code ?? "#\(s.number)").font(.caption2.bold()).foregroundStyle(.black)
|
||||
.padding(.horizontal, 3).background(Color.yellow).offset(y: -14)
|
||||
}
|
||||
.offset(x: r.minX, y: r.minY)
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(width: size.width, height: size.height, alignment: .topLeading)
|
||||
.allowsHitTesting(false)
|
||||
}
|
||||
|
||||
// MARK: Right side (preview + PM buttons)
|
||||
|
||||
private var sidePanel: some View {
|
||||
VStack(spacing: 12) {
|
||||
ZStack {
|
||||
Color.black
|
||||
if let image { Image(nsImage: image).resizable().scaledToFit() } else { ProgressView() }
|
||||
if let image {
|
||||
Image(nsImage: image).resizable().scaledToFit()
|
||||
.overlay { GeometryReader { geo in numberBoxes(in: geo.size) } }
|
||||
} else { ProgressView() }
|
||||
}
|
||||
.frame(minHeight: 280)
|
||||
|
||||
|
||||
Reference in new issue
Block a user