Skip to content

Conversation

@Supermagnum
Copy link

  • I have read the contribution guidelines.

  • I have updated the documentation, if applicable.

  • I have ensured that the change is tested somewhere.

  • I have followed the prevailing code style (for history readability and limit conflicts for maintainance).

-->

Description

This PR adds the MrIMU plugin, a Meshroom plugin that integrates IMU (Inertial Measurement Unit) data from accelerometers and gyroscopes into photogrammetry workflows. The plugin enables users to improve camera pose estimation by applying IMU-derived orientation constraints to StructureFromMotion results, particularly useful for maintaining vertical axis stability and correcting drift in camera tracking.

The plugin supports loading IMU data from:

  • OpenCamera-Sensors CSV files: Standard format exported by OpenCamera Android app
  • CAMM metadata from MP4 files: GoPro format (detection implemented, full extraction placeholder for future enhancement)

Key capabilities:

  • Gravity vector extraction using low-pass Butterworth filtering
  • IMU orientation estimation and Z-axis locking to gravity direction
  • Configurable IMU influence weighting (0.0 to 1.0) for blending IMU and optical data
  • Coordinate transformation from Android sensor frame to Meshroom's world frame

Features list

  • LoadIMUData node: Load and preprocess IMU data from CSV files or MP4 metadata
  • ApplyIMUConstraints node: Apply IMU-derived orientation constraints to SfM camera poses
  • Gravity vector extraction using Butterworth filter
  • Coordinate frame transformation (Android sensor to world frame)
  • Configurable IMU influence weighting
  • Z-axis locking to gravity direction option
  • Complete plugin structure following Meshroom plugin architecture
  • Documentation (README.md) with installation and usage instructions
  • Code quality compliance (black, flake8, pylint, mypy, isort)
  • Plugin integration in Meshroom README.md

Implementation remarks

Plugin Structure:

  • Plugin located in plugins/MrIMU/ following Meshroom's plugin directory structure
  • Nodes are in plugins/MrIMU/meshroom/nodes/ as required by Meshroom's plugin discovery mechanism
  • Utility functions (imu_utils.py) placed in meshroom/ directory to avoid being treated as node classes
  • Lazy imports used in node files to prevent blocking plugin discovery during module import

Key Design Decisions:

  1. Lazy Import Pattern: The imu_utils module is imported lazily in processChunk() methods rather than at module level. This ensures plugin discovery works even if there are import issues, and errors are only raised when nodes are actually executed.

  2. Import Compatibility: Multiple import fallback methods are implemented (sys.path, importlib.util, imp) to ensure compatibility across different Python versions and Meshroom environments.

  3. Coordinate Transformations: Android sensor coordinate frame (X=East, Y=North, Z=Up) is transformed to Meshroom's world frame using the standard transformation: [Y, Z, -X].

  4. Butterworth Filter: Gravity vector extraction uses scipy's Butterworth filter with configurable cutoff frequency (default 0.1 Hz) to separate gravity from dynamic acceleration.

  5. IMU Weight Blending: Camera poses are corrected by blending optical SfM results with IMU orientation using a configurable weight parameter, allowing users to balance between pure optical tracking and IMU constraints.

Testing:

  • Plugin structure verified against Meshroom plugin documentation
  • Code quality tests passed (black, flake8, pylint, mypy, isort)
  • Manual testing in development Meshroom environment confirmed plugin loads and nodes appear in palette
  • Import tests verify all dependencies resolve correctly

Dependencies:

  • numpy >= 1.19.0 (for array operations)
  • scipy >= 1.5.0 (for Butterworth filter)
  • pandas >= 2.0.0 (for CSV parsing)

Future Enhancements:

  • Full CAMM metadata extraction from MP4 files (currently placeholder)
  • Support for additional IMU data formats
  • Real-time IMU data streaming
  • Advanced sensor fusion algorithms

Note: The plugin has been tested in the development Meshroom environment. For the prebuilt Meshroom 2023.3.0, additional configuration may be required as that version appears to have different plugin loading behavior.

- Add LoadIMUData node for loading and processing IMU data from OpenCamera-Sensors CSV or CAMM metadata
- Add ApplyIMUConstraints node for applying IMU orientation constraints to SfM camera poses
- Support gravity vector extraction using low-pass Butterworth filter
- Support Z-axis locking to gravity direction
- Configurable IMU influence weight (0.0 to 1.0)
- Includes comprehensive code quality improvements and test results
- Moved MrIMU plugin from root to plugins/MrIMU/ following Meshroom plugin structure
- Updated start.sh to point MESHROOM_PLUGINS_PATH to new location
- Plugin structure now matches Meshroom documentation requirements
- All plugin files verified and imports working correctly
@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.86%. Comparing base (73a9715) to head (62bed60).
⚠️ Report is 8 commits behind head on develop.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2942      +/-   ##
===========================================
- Coverage    80.88%   80.86%   -0.02%     
===========================================
  Files           59       59              
  Lines         7857     7860       +3     
===========================================
+ Hits          6355     6356       +1     
- Misses        1502     1504       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@natowi
Copy link
Member

natowi commented Nov 26, 2025

Thank you, really nice contribution.
(btw. here are two other capturing apps https://github.com/OSUPCVLab/mobile-ar-sensor-logger https://github.com/DavidGillsjo/VideoIMUCapture-Android)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants