Visual SLAM

The Visual SLAM(Simultaneous Localization and Mapping) creates and saves 3 dimensional maps of target spaces for more exquisite AR project.

Starting / Stopping the Tracker
Starting / Stopping map generation, Saving map
Set Rendering Options

Starting / Stopping the Tracker

To start / stop Tracker, refer to the following code.

SlamActivity.java

@Override
protected void onResume() {
    ...
    TrackerManager.getInstance().startTracker(TrackerManager.TRACKER_TYPE_SLAM);
    ...
}

@Override
protected void onPause() {
    ...
    TrackerManager.getInstance().stopTracker();
    ...
}

Starting / Stopping map generation, Saving map

  • To start a map generation, refer to the following code.
TrackerManager.getInstance().findSurface();
  • To stop generating a map, refer to the following code.
TrackerManager.getInstance().quitFindingSurface();
  • Saving map is only possible while tracking. When saving the generated map data to a file, refer to the following code for the file storage location.

SlamActivity.java

public void onClick(View view) {
    switch (view.getId()) {
        ...
        case R.id.save_map:
            ...
            SurfaceThumbnail surfaceThumbnail = TrackerManager.getInstance().saveSurfaceData(mapFileName);
            ...
    }
}

Set Rendering Options

Feature points, SLAM initialization progress, Axis, and Surface mesh information can be displayed by option setting. Refer to the following code.

ObjectTrackerRenderer.java

@Override
onSurfaceCreated(GL10 unused, EGLConfig config) {
    ...
    if (trackerType == TrackerManager.TRACKER_TYPE_SLAM) {
      backgroundRenderHelper.setRenderingOption(BackgroundRenderer.RenderingOption.FEATURE_RENDERER, BackgroundRenderer.RenderingOption.PROGRESS_RENDERER, BackgroundRenderer.RenderingOption.SURFACE_MESH_RENDERER, BackgroundRenderer.RenderingOption.AXIS_RENDERER);
    }
    ...
}

See ‘BackgroundRenderer.RenderingOption enum' for option settings.