UNPKG

bowling-analysis-system

Version:

A comprehensive system for analyzing bowling techniques using video processing and metrics calculation

125 lines (109 loc) 3.7 kB
/** * @module config/system-config * @description Centralized configuration for the bowling analysis system */ /** * Standard event names to use throughout the application */ const EVENT_NAMES = { RELEASE_POINT: 'releasePoint', FRONT_FOOT_LANDING: 'frontFootLanding', BACK_FOOT_LANDING: 'backFootLanding' }; /** * Mapping from legacy event names to standardized event names */ const LEGACY_EVENT_MAPPINGS = { // Old naming convention 'ball_release': EVENT_NAMES.RELEASE_POINT, 'left_foot_plant': EVENT_NAMES.FRONT_FOOT_LANDING, 'right_foot_plant': EVENT_NAMES.BACK_FOOT_LANDING, // Alternative naming 'ballRelease': EVENT_NAMES.RELEASE_POINT, 'leftFootPlant': EVENT_NAMES.FRONT_FOOT_LANDING, 'rightFootPlant': EVENT_NAMES.BACK_FOOT_LANDING }; /** * Core threshold values to be used across the system */ const THRESHOLDS = { // Confidence thresholds CONFIDENCE: 0.75, // General confidence threshold EVENT_CONFIDENCE: 0.7, // Confidence threshold for events BIAS_CONFIDENCE: 0.75, // Confidence threshold for bias KEYPOINT_CONFIDENCE: 0.3, // Confidence threshold for keypoints // Pattern detection thresholds CORRELATION: 0.72, // Correlation threshold SIGNIFICANCE: 0.22, // Significance threshold // Keypoint thresholds MIN_KEYPOINTS: 5, // Minimum number of valid keypoints required }; /** * Pattern detection configuration */ const PATTERN_DETECTION = { WINDOW_SIZE: 9, // Standard window size for pattern detection ADAPTIVE_WINDOW: true, // Whether to use adaptive window sizing SMOOTHING_FACTOR: 0.3, // Smoothing factor for time series }; /** * Event sequence validation */ const EVENT_VALIDATION = { SEQUENCE: [ EVENT_NAMES.BACK_FOOT_LANDING, EVENT_NAMES.FRONT_FOOT_LANDING, EVENT_NAMES.RELEASE_POINT ], MIN_CONSECUTIVE_FRAMES: 3 // Minimum consecutive frames for foot plant detection }; /** * Get standardized event name * @param {string} eventName - Original event name * @returns {string} Standardized event name */ function getStandardEventName(eventName) { return LEGACY_EVENT_MAPPINGS[eventName] || eventName; } /** * Validate event sequence * @param {Object} events - Event object with frame properties * @returns {Object} Validation result {valid, reason} */ function validateEventSequence(events) { const result = { valid: true, reason: '' }; // Check if we have all required events const hasBackFoot = events[EVENT_NAMES.BACK_FOOT_LANDING] && events[EVENT_NAMES.BACK_FOOT_LANDING].frame !== undefined; const hasFrontFoot = events[EVENT_NAMES.FRONT_FOOT_LANDING] && events[EVENT_NAMES.FRONT_FOOT_LANDING].frame !== undefined; const hasRelease = events[EVENT_NAMES.RELEASE_POINT] && events[EVENT_NAMES.RELEASE_POINT].frame !== undefined; if (!hasBackFoot || !hasFrontFoot || !hasRelease) { result.valid = false; result.reason = 'Missing required events'; return result; } // Check sequence const backFootFrame = events[EVENT_NAMES.BACK_FOOT_LANDING].frame; const frontFootFrame = events[EVENT_NAMES.FRONT_FOOT_LANDING].frame; const releaseFrame = events[EVENT_NAMES.RELEASE_POINT].frame; if (!(backFootFrame < frontFootFrame && frontFootFrame < releaseFrame)) { result.valid = false; result.reason = 'Events are in incorrect sequence'; return result; } return result; } module.exports = { EVENT_NAMES, LEGACY_EVENT_MAPPINGS, THRESHOLDS, PATTERN_DETECTION, EVENT_VALIDATION, getStandardEventName, validateEventSequence };