refactor(results): support class-based detection summaries
This commit is contained in:
@@ -1,149 +0,0 @@
|
||||
/**
|
||||
* Detection mode configurations to support dynamic UI behavior
|
||||
*/
|
||||
|
||||
export interface DetectionTypeConfig {
|
||||
id: string;
|
||||
label: string;
|
||||
color: string;
|
||||
}
|
||||
|
||||
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)',
|
||||
},
|
||||
defected_sign_board: {
|
||||
id: 'defected_sign_board',
|
||||
label: 'Defect Sign Board',
|
||||
color: 'var(--chart-2)',
|
||||
},
|
||||
road_crack: {
|
||||
id: 'road_crack',
|
||||
label: 'Road Crack',
|
||||
color: 'var(--chart-3)',
|
||||
},
|
||||
damaged_road_marking: {
|
||||
id: 'damaged_road_marking',
|
||||
label: 'Damage Road Mark',
|
||||
color: 'var(--chart-4)',
|
||||
},
|
||||
good_sign_board: {
|
||||
id: 'good_sign_board',
|
||||
label: 'Good Sign Board',
|
||||
color: 'var(--chart-5)',
|
||||
},
|
||||
drain_issue: {
|
||||
id: 'drain_issue',
|
||||
label: 'Drain Issue',
|
||||
color: 'var(--chart-6)',
|
||||
},
|
||||
good_culvert: {
|
||||
id: 'good_culvert',
|
||||
label: 'Good Culvert',
|
||||
color: 'var(--chart-5)',
|
||||
},
|
||||
defective_culvert: {
|
||||
id: 'defective_culvert',
|
||||
label: 'Defective Culvert',
|
||||
color: 'var(--chart-8)',
|
||||
},
|
||||
};
|
||||
|
||||
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'],
|
||||
},
|
||||
gemini_video: {
|
||||
id: 'gemini_video',
|
||||
label: 'Gemini AI Analysis',
|
||||
enabledTypes: [
|
||||
'pothole',
|
||||
'defected_sign_board',
|
||||
'road_crack',
|
||||
'damaged_road_marking',
|
||||
'good_sign_board',
|
||||
'drain_issue',
|
||||
'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);
|
||||
};
|
||||
Reference in New Issue
Block a user