InfiniTAM v3 Documentation

repository·master·Indexed 21 days ago

https://github.com/victorprad/infinitam

A framework for large-scale, real-time 3D reconstruction with loop closure, supporting both CPU and GPU (CUDA) accelerated processing. Includes guides for CMake builds, offline and live reconstruction, Android integration via the InfiniTAMApp class, and UI management using the UIEngine singleton.

Tokens
2.5K
Snippets
10
Records
14
Agent score
76%

What's inside InfiniTAM

  1. Optimize ITMVoxel performance on certain GPUs

    master
    In ITMLibDefines.h, padding the ITMVoxel data structure with one extra byte may improve performance on specific NVIDIA GPUs (e.g., GTX 680), though this effect is hardware-dependent and may not apply to others (e.g., GTX 780).
  2. Run InfiniTAM sample programs

    master

    The build process produces two main executables:

    • InfiniTAM: The main sample program (includes visualization).
    • InfiniTAM_cli: A version without visualization.

    Live Reconstruction

    If compiled with OpenNI support, you can run live reconstruction out-of-the-box. If you have calibration data for your device, pass it as the first argument:

    ./InfiniTAM <path_to_calib_file>

    Offline Processing

    If OpenNI support was not compiled, use the program for offline processing by providing calibration and image paths. The image paths use sprintf style masks (e.g., %04i for sequential numbering):

    ./InfiniTAM <path_to_calib_file> <image_path_pattern_1> <image_path_pattern_2>
    # Live reconstruction with calibration
    $ ./InfiniTAM Teddy/calib.txt
    
    # Offline processing with image sequences
    $ ./InfiniTAM Teddy/calib.txt Teddy/Frames/%04i.ppm Teddy/Frames/%04i.pgm
  3. Build InfiniTAM v3 using CMake

    master

    To compile InfiniTAM, use the standard CMake build process. You can optionally provide the path to OpenNI2 using the -DOPEN_NI_ROOT flag to enable live hardware support.

    If you wish to generate a reference manual, run doxygen on the provided Doxyfile after the build process.

    $ mkdir build
    $ cd build
    $ cmake /path/to/InfiniTAM -DOPEN_NI_ROOT=/path/to/OpenNI2/
    $ make
    
    # To generate documentation
    $ doxygen Doxyfile
  4. InfiniTAM v3 System Requirements

    master

    The following libraries are required or optional for building InfiniTAM. Note that skipping optional libraries will reduce the system's functionality.

    Required

    • cmake: Required for Linux builds (e.g., 2.8.10.2 or 3.2.3).
    • OpenGL / GLUT: Required for visualization (e.g., freeglut 2.8.0 or 3.0.0).

    Optional

    • CUDA: Required for all GPU accelerated code (e.g., version 6.0 or 7.0).
    • OpenNI: Required for live images from compatible hardware (e.g., version 2.2.0.33).
    • libpng: Allows reading PNG input files.
    • FFMPEG: Allows writing and playback of lossless FFV1 encoded videos.
    • librealsense / librealsense2: Allows live images from Intel RealSense cameras.
    • libuvc: Deprecated alternative to librealsense (currently works only with branch olafkaehler/master).
    • doxygen: Builds the reference manual.
  5. Set up OpenNI for Android

    master

    To get OpenNI running on Android, you need to package the OpenNI2 sources specifically for the Android platform.

    1. Obtain the latest OpenNI2 source code.
    2. Navigate to the OpenNI2/Packaging directory.
    3. Run the release version script with the android argument:
    ./ReleaseVersion.py android

    Note: Accessing devices via libusb on recent Android versions (e.g., 4.4 and 5.0) may encounter significant compatibility issues.

  6. Configure the Android SDK path

    master

    To enable the Android build environment, you must specify the location of your Android SDK. Create a file named local.properties in the project root with the following content, replacing the path with your actual SDK location:

    sdk.dir=/path/to/your/local/android/android-sdk-linux

    sdk.dir=/path/to/your/local/android/android-sdk-linux
  7. Initialize and run the UIEngine

    master

    The UIEngine is a singleton used to manage the graphical user interface and the main execution loop for InfiniTAM applications. To use it, call Instance() to get the singleton pointer, then call Initialise() with the necessary engine components and command-line arguments, and finally call Run() to start the main loop.

    Required parameters for Initialise:

    • argc, argv: Command line arguments.
    • imageSource: A pointer to an InputSource::ImageSourceEngine.
    • imuSource: A pointer to an InputSource::IMUSourceEngine.
    • mainEngine: A pointer to the ITMLib::ITMMainEngine.
    • outFolder: A string pointer defining the output directory.
    • deviceType: The ITMLib::ITMLibSettings::DeviceType being used.
    // Access the singleton
    InfiniTAM::Engine::UIEngine* ui = InfiniTAM::Engine::UIEngine::Instance();
    
    // Initialize with required engine components
    ui->Initialise(argc, argv, imageSource, imuSource, mainEngine, outFolder, deviceType);
    
    // Start the UI loop
    ui->Run();
    
    // Clean up when finished
    ui->Shutdown();
  8. Configure a release keystore for Android builds

    master

    To build the project in release mode, you must generate a keystore and provide its credentials to the build system via an ant.properties file.

    1. Generate a keystore using keytool:
    keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
    1. Create a file named ant.properties and add your keystore details:
    key.store=my-release-key.keystore
    key.alias=alias_name
    key.store.password=xxx
    key.alias.password=xxx
  9. Build and install InfiniTAM for Android

    master

    Follow these steps in order to compile the library and install the Android application:

    1. Build the ITMLib static library: Navigate to InfiniTAM/ITMLib and run the make command targeting the Android Makefile.
    2. Run NDK build: Navigate back to InfiniTAM/android and execute ndk-build.
    3. Install via Ant: While still in InfiniTAM/android, run ant release install to build the release version and install it on a connected device.
    # Step 1: Build ITMLib
    cd InfiniTAM/ITMLib
    make -f Android.mk libITMLib.a
    
    # Step 2: NDK Build
    cd ../android
    ndk-build
    
    # Step 3: Release Install
    ant release install
  10. Troubleshoot Mac OS X CUDA/Clang issues

    master

    On Mac OS X 10.9, conflicts between libc++ and libstdc++ may occur when using CUDA, resulting in Undefined symbols for architecture x86_64 errors.

    To resolve this, specify the following flag when using clang as the compiler:

    CMAKE_CXX_FLAGS=-stdlib=libstdc++

    Alternatively, future CUDA versions might require specifying the host compiler:

    CUDA_HOST_COMPILER=/usr/bin/clang
  11. Monitor InfiniTAMApp initialization and performance

    master

    When interacting with the InfiniTAMApp via JNI, you can query the application state and performance metrics using the following methods:

    • IsInitialized(): Returns a bool indicating if the application has been successfully initialized.
    • getAverageTime(): Returns a float representing the average processing time, useful for monitoring frame rates and system load.
  12. Use the InfiniTAMApp class for Android integration

    master

    The InfiniTAMApp class serves as the primary entry point for integrating InfiniTAM into an Android application via JNI. It manages the lifecycle of the engine, including OpenGL initialization, frame processing, and recording modes.

    Key lifecycle methods include:

    • Instance(): Returns the singleton instance of the application.
    • InitGL(): Initializes the OpenGL context.
    • ResizeGL(int newWidth, int newHeight): Updates the OpenGL viewport size.
    • RenderGL(): Executes the rendering loop.
    • StartProcessing(int useLiveCamera): Begins the data processing pipeline (passing 1 for live camera usage).
    • StopProcessing(): Halts the processing pipeline.
    • toggleRecordingMode(): Switches between recording and non-recording modes for depth and color video output.
    // Access the singleton instance
    InfiniTAMApp* app = InfiniTAMApp::Instance();
    
    // Initialize and start
    app->InitGL();
    app->StartProcessing(1); // 1 for live camera
    
    // In the render loop
    app->RenderGL();
    
    // Stop
    app->StopProcessing();