Enhance annotations: save/download, fallback classes, photo mode icons

Add local annotation save fallback, PNG+txt download with drawn boxes,
shared classColors helper, photo mode icon toggles, and react-dropzone
/ react-icons dependencies.
This commit is contained in:
Armen Rohalov
2026-04-17 23:33:00 +03:00
parent 567092188d
commit 63cc18e788
15 changed files with 782 additions and 218 deletions
+24
View File
@@ -0,0 +1,24 @@
const CLASS_COLORS = [
'#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#FF00FF', '#00FFFF',
'#800000', '#008000', '#000080', '#808000', '#800080', '#008080',
]
export const FALLBACK_CLASS_NAMES = [
'Car', 'Person', 'Truck', 'Bicycle', 'Motorcycle', 'Bus',
'Animal', 'Tree', 'Building', 'Sign', 'Boat', 'Plane',
]
export function getClassColor(classNum: number): string {
const base = classNum % 20
return CLASS_COLORS[base % CLASS_COLORS.length]
}
export function getPhotoModeSuffix(classNum: number): string {
const mode = Math.floor(classNum / 20)
return mode === 1 ? ' (winter)' : mode === 2 ? ' (night)' : ''
}
export function getClassNameFallback(classNum: number): string {
const base = classNum % 20
return FALLBACK_CLASS_NAMES[base % FALLBACK_CLASS_NAMES.length] ?? `#${classNum}`
}