Try MAXST AR Fusion Tracker Now ✨

Visual SLAM

Related documentations
Map Manager
Tracker Coordinate System
Visual SLAM Learning Guide

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

Please refer Visual SLAM Learning Guide to create a map more precisely while scanning 3D space.

Start / Stop Tracker
Start / Stop Map Creation & Map Saving
Set Rendering Options

Start / Stop 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();
    ...
}

Start / Stop Map Creation & Map Saving

  • 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. Refer to the following code for the file storage location when you save the generated map data as a file.

>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, and axis can be created with 'FeaturePoint', 'Axis' class. Refer to the following code.

>ObjectTrackerRenderer.java

private FeaturePointCPU featurePoint;
private Axis axis;

@Override
onSurfaceCreated(GL10 unused, EGLConfig config) {
    ...
    backgroundCameraQuad = new BackgroundCameraQuad();
    featurePoint = new FeaturePointCPU();
    axis = new Axis();
    Bitmap blueBitmap = MaxstARUtil.getBitmapFromAsset("bluedot.png", activity.getAssets());
    Bitmap redBitmap = MaxstARUtil.getBitmapFromAsset("reddot.png", activity.getAssets());
    featurePoint.setFeatureImage(blueBitmap, redBitmap);
    featurePoint.setTrackState(true);
    ...
}

@Override
onDrawFrame(GL10 unused) {
    featurePoint.draw(TrackerManager.getInstance(), projectionMatrix);
    if (trackingResult.getCount() > 0) {
        Trackable trackable = trackingResult.getTrackable(0);

        axis.setTransform(trackable.getPoseMatrix());
        axis.setTranslate(0, 0, 0);
        axis.setScale(0.3f, 0.3f, 0.3f);
        axis.setProjectionMatrix(projectionMatrix);
        axis.draw();
    }
}

Preferably, use landscape left mode (screen orientation) for Visual SLAM.