153 lines
4.1 KiB
TypeScript
153 lines
4.1 KiB
TypeScript
/**
|
|
* Detection mode configurations to support dynamic UI behavior
|
|
*/
|
|
|
|
export interface DetectionTypeConfig {
|
|
id: string;
|
|
label: string;
|
|
color: string;
|
|
countKey: string; // The key in summary object from API (e.g., unique_pothole)
|
|
listKey: string; // The key for the list of detections in DetectionData (e.g., pothole_list)
|
|
frameCountKey: string; // The key in per-frame count object (e.g., pothole)
|
|
}
|
|
|
|
export interface DetectionModeConfig {
|
|
id: string;
|
|
label: string;
|
|
enabledTypes: string[]; // IDs of detection types to show in this mode
|
|
}
|
|
|
|
export const DETECTION_TYPES: Record<string, DetectionTypeConfig> = {
|
|
pothole: {
|
|
id: 'pothole',
|
|
label: 'Pothole',
|
|
color: 'var(--chart-1)',
|
|
countKey: 'unique_pothole',
|
|
listKey: 'pothole_list',
|
|
frameCountKey: 'pothole',
|
|
},
|
|
defected_sign_board: {
|
|
id: 'defected_sign_board',
|
|
label: 'Defect Sign Board',
|
|
color: 'var(--chart-2)',
|
|
countKey: 'unique_defected_sign_board',
|
|
listKey: 'defected_sign_board_list',
|
|
frameCountKey: 'defected_sign_board',
|
|
},
|
|
road_crack: {
|
|
id: 'road_crack',
|
|
label: 'Road Crack',
|
|
color: 'var(--chart-3)',
|
|
countKey: 'unique_road_crack',
|
|
listKey: 'road_crack_list',
|
|
frameCountKey: 'road_crack',
|
|
},
|
|
damaged_road_marking: {
|
|
id: 'damaged_road_marking',
|
|
label: 'Damage Road Mark',
|
|
color: 'var(--chart-4)',
|
|
countKey: 'unique_damaged_road_marking',
|
|
listKey: 'damaged_road_marking_list',
|
|
frameCountKey: 'damaged_road_marking',
|
|
},
|
|
good_sign_board: {
|
|
id: 'good_sign_board',
|
|
label: 'Good Sign Board',
|
|
color: 'var(--chart-5)',
|
|
countKey: 'unique_good_sign_board',
|
|
listKey: 'good_sign_board_list',
|
|
frameCountKey: 'good_sign_board',
|
|
},
|
|
drain_issue: {
|
|
id: 'drain_issue',
|
|
label: 'Drain Issue',
|
|
color: 'var(--chart-6)',
|
|
countKey: 'unique_drain_issue',
|
|
listKey: 'drain_issue_list',
|
|
frameCountKey: 'drain_issue',
|
|
},
|
|
good_culvert: {
|
|
id: 'good_culvert',
|
|
label: 'Good Culvert',
|
|
color: 'var(--chart-5)',
|
|
countKey: 'unique_good_culvert',
|
|
listKey: 'good_culvert_list',
|
|
frameCountKey: 'good_culvert',
|
|
},
|
|
defective_culvert: {
|
|
id: 'defective_culvert',
|
|
label: 'Defective Culvert',
|
|
color: 'var(--chart-8)',
|
|
countKey: 'unique_defective_culvert',
|
|
listKey: 'defective_culvert_list',
|
|
frameCountKey: 'defective_culvert',
|
|
},
|
|
};
|
|
|
|
export const DETECTION_MODES: Record<string, DetectionModeConfig> = {
|
|
yolo: {
|
|
id: 'yolo',
|
|
label: 'YOLO Detection',
|
|
enabledTypes: [
|
|
'pothole',
|
|
'defected_sign_board',
|
|
'road_crack',
|
|
'damaged_road_marking',
|
|
'good_sign_board',
|
|
'drain_issue',
|
|
],
|
|
},
|
|
yolo_vl: {
|
|
id: 'yolo_vl',
|
|
label: 'YOLO-VL Detection',
|
|
enabledTypes: [
|
|
'pothole',
|
|
'defected_sign_board',
|
|
'road_crack',
|
|
'damaged_road_marking',
|
|
'good_sign_board',
|
|
'drain_issue',
|
|
],
|
|
},
|
|
'pothole-detection': {
|
|
id: 'pothole-detection',
|
|
label: 'Pothole Detection',
|
|
enabledTypes: ['pothole', 'road_crack', 'damaged_road_marking', 'drain_issue'],
|
|
},
|
|
'sign-board-detection': {
|
|
id: 'sign-board-detection',
|
|
label: 'Signboard Detection',
|
|
enabledTypes: ['defected_sign_board', 'good_sign_board'],
|
|
},
|
|
'pot-sign-detection': {
|
|
id: 'pot-sign-detection',
|
|
label: 'Pothole & Signboard Detection',
|
|
enabledTypes: [
|
|
'pothole',
|
|
'defected_sign_board',
|
|
'road_crack',
|
|
'damaged_road_marking',
|
|
'good_sign_board',
|
|
'drain_issue',
|
|
],
|
|
},
|
|
culvert_detection: {
|
|
id: 'culvert_detection',
|
|
label: 'Culvert Detection',
|
|
enabledTypes: ['good_culvert', 'defective_culvert'],
|
|
},
|
|
};
|
|
|
|
// Fallback config for unknown modes
|
|
export const DEFAULT_DETECTION_MODE: DetectionModeConfig = DETECTION_MODES['pot-sign-detection'];
|
|
|
|
export const getDetectionModeConfig = (mode?: string): DetectionModeConfig => {
|
|
if (!mode) return DEFAULT_DETECTION_MODE;
|
|
return DETECTION_MODES[mode] || DEFAULT_DETECTION_MODE;
|
|
};
|
|
|
|
export const getEnabledDetectionTypes = (mode?: string): DetectionTypeConfig[] => {
|
|
const config = getDetectionModeConfig(mode);
|
|
return config.enabledTypes.map((typeId) => DETECTION_TYPES[typeId]).filter(Boolean);
|
|
};
|