- Add ClassificationManager singleton to handle class name mappings
- Load class names dynamically from training dataset.yaml (source of truth)
- Remove hardcoded 96-class mapping from YOLOInferenceEngine
- Add SnakeYAML dependency for YAML parsing
- Update all classNames references to use ClassificationManager
- Ensure consistency between model training data and runtime classification
Related todos: #create-classification-module
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Replace hardcoded NUM_DETECTIONS, NUM_CLASSES, NMS_OUTPUT_FEATURES_PER_DETECTION
with runtime extracted values from ONNX model session
- Add extractModelMetadata() method to dynamically determine model properties
- Update parseNMSOutput, matToTensorArray, and postprocessResults to use dynamic variables
- Fallback to constants if runtime extraction fails for safety
- Replace remaining magic numbers with named constants
Related todos: #extract-model-metadata
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Created PGHLog utility with "PGH - " prefix for easy log filtering
- Enhanced MLResult with specific error types (MLErrorType enum)
- Updated MLInferenceEngine interface to use MLResult pattern
- Converted all Log.* calls to PGHLog.* in core components
- Added type-specific error recovery strategies with onErrorType()
- Improved error propagation and debugging capabilities
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Replaced complex color format conversion (20 lines) with ensureBGRFormat() utility
- Simplified RGB conversion logic using ensureRGBFormat() utility
- Reduced preprocessOriginalStyle from 13 lines to 3 lines with safeResize()
- Added comprehensive preprocessing utilities for code reuse
- Improved maintainability and reduced code duplication
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Method Decomposition Improvements:
- Extract complex coordinate transformation logic from parseNMSOutput method
- Create TransformedCoordinates data class for type-safe coordinate handling
- Add transformCoordinates() method with clear parameter naming
- Reduce parseNMSOutput method complexity by 60+ lines
Code Quality Benefits:
- Separate coordinate transformation concerns from detection parsing
- Eliminate duplicate transformation logic across different modes
- Improve testability of coordinate transformation independently
- Better readability with focused, single-responsibility methods
Maintainability Impact:
- Coordinate transformation logic now in one place for easier debugging
- Clear separation between transformation logic and detection creation
- Type-safe coordinate handling with data class
- Foundation for unit testing coordinate transformations
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Improvements:
- Create YOLOConfig data class with all inference settings consolidated
- Add CoordinateMode and PreprocessingTechnique enums for type safety
- Update YOLOInferenceEngine constructor to accept configurable settings
- Replace scattered constants with config usage in key methods
- Enable runtime configuration of model file, thresholds, and processing options
Maintainability Benefits:
- All YOLO settings in one place for easy adjustment
- Type-safe enums prevent configuration errors
- Default values maintain backward compatibility
- Cleaner separation between configuration and implementation
Performance Impact:
- Thread pool size now configurable via config.threadPoolSize
- Confidence and processing thresholds easily adjustable
- Foundation for A/B testing different configurations
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
High Priority Fixes:
- Fix thread pool management: Add shared preprocessingExecutor to prevent creating new thread pools per detection
- Add proper thread pool shutdown with grace period in cleanup() method
- Remove memory leak from repeated Executors.newFixedThreadPool() calls
Code Quality Infrastructure:
- Add MatUtils.kt with safe Mat resource management extension functions
- Add MLResult.kt with standardized error handling for ML operations
- Prepare foundation for systematic error handling improvements
Performance Impact:
- Eliminates thread pool creation overhead during inference
- Reduces memory pressure from abandoned thread pools
- Maintains all original ML detection functionality
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fix DetectionController initialization crash by properly setting up dependency injection
- Update all function signatures to use new MLDetection type instead of legacy Detection
- Remove duplicate class mapping and getClassIdFromName helper method from ScreenCaptureService
- Update EnhancedOCR to work with new MLDetection and BoundingBox types
- Comment out legacy YOLOOnnxDetector references in MainActivity and DetectionController
- Exclude legacy YOLOOnnxDetector.kt from compilation (moved to .bak)
- Fix missing return statement in YOLOInferenceEngine.detectWithMat method
- Add build commands documentation to CLAUDE.md for future reference
- Ensure all preprocessing and detection functionality preserved from original
Architecture Changes:
- ScreenCaptureService now properly uses MLInferenceEngine interface
- DetectionController updated to use MLInferenceEngine instead of legacy detector
- All detection workflows now use unified MLDetection and BoundingBox types
- Maintained 100% backward compatibility of ML detection capabilities
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
ARCH-002: Extract ML Inference Engine
- Created MLInferenceEngine interface with async detection methods
- Implemented YOLOInferenceEngine preserving ALL YOLOOnnxDetector functionality:
* Complete 96-class mapping with exact original class names
* All preprocessing techniques (ultralytics, enhanced, sharpened, original)
* All coordinate transformation modes (HYBRID, LETTERBOX, DIRECT)
* Weighted NMS and cross-class NMS for semantically related classes
* Confidence mapping and mobile optimization
* Debug features (class filtering, confidence logging)
* Letterbox resize with proper aspect ratio preservation
* CLAHE contrast enhancement and sharpening filters
- Created ImagePreprocessor utility for reusable preprocessing operations
* Configurable preprocessing with letterboxing, normalization, color conversion
* Coordinate transformation utilities for model-to-image space conversion
* Support for different preprocessing configurations
- Updated ScreenCaptureService to use new MLInferenceEngine:
* Replaced YOLOOnnxDetector with MLInferenceEngine dependency injection
* Added class name to class ID mapping for compatibility
* Maintained all existing detection pipeline functionality
* Proper async/await integration with coroutines
- Applied preferred code style throughout:
* Opening braces on new lines for functions and statements
* snake_case for local variables to distinguish from members/parameters
* Consistent formatting matching project standards
- Removed obsolete YOLO implementations (YOLODetector, YOLOTFLiteDetector)
- Preserved all sophisticated ML features: TTA, multi-preprocessing, confidence mapping
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>