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>