Commit Graph
3 Commits
Author SHA1 Message Date
john-okeefe 36537e3728 Add panel-aware keyboard shortcuts to reader
Extend keyboard navigation to support panel mode when enabled.

Changes:
- Check for panel-mode attribute before routing key events
- Route Arrow keys and Vim keys (h/l) to panel navigation in panel mode
- Add 'P' key to toggle panel mode
- Add 'Escape' key to exit panel mode
- Maintain backward compatibility with existing page navigation

When panel mode is active:
- ArrowRight/l: next panel
- ArrowLeft/h: previous panel
- Escape/P: exit panel mode

When panel mode is inactive:
- ArrowRight/l: next page (existing behavior)
- ArrowLeft/h: previous page (existing behavior)
- P: enter panel mode (new feature)
2026-04-13 16:43:32 -04:00
john-okeefe ffaceaf962 Add panel detection module with multi-tier fallback system
Implement a comprehensive panel detection system for manga and comics
with automatic fallback chain for maximum compatibility.

Core detector (detector.js):
- PanelDetector class with in-memory caching
- Lazy-loading of OpenCV and TensorFlow.js
- Validation logic to filter poor detections
- Cache management to avoid re-detection

OpenCV edge detection (opencv.js):
- Canny edge detection for panel boundaries
- Contour finding with bounding box extraction
- Size and aspect ratio filtering
- Reading order sorting (top-to-bottom, left-to-right)

ML-based detection (coco-ssd.js):
- COCO-SSD pre-trained model integration
- Object detection for irregular panel layouts
- Rectangular filtering for panel-like regions
- Handles edge cases where edge detection fails

Grid-based fallback (grid.js):
- Lightweight 3x3 grid detection
- Empty cell detection via alpha channel analysis
- Adjacent panel merging algorithm
- Always works as final fallback

The detection pipeline tries OpenCV first (fast, accurate),
falls back to ML detection if validation fails,
and uses grid detection as ultimate baseline.
2026-04-13 16:43:25 -04:00
john-okeefe 1684204e75 Add panel detection dependencies
Add ML and computer vision libraries for manga/comic panel detection:
- @techstark/opencv-js: OpenCV.js for edge detection and contour analysis
- @tensorflow/tfjs: TensorFlow.js for ML-based detection fallback
- @tensorflow-models/coco-ssd: Pre-trained COCO-SSD model for object detection

These libraries enable a multi-tier panel detection pipeline:
1. OpenCV edge detection (fast, ~80% accuracy)
2. ML-based detection with COCO-SSD (handles irregular layouts)
3. Grid-based fallback (always works)

All libraries are lazy-loaded on-demand to minimize initial bundle size.
2026-04-13 16:43:20 -04:00