Skip to content

Need help understanding offline slam tracker #53

Description

@kmatzen

I think I'm misunderstanding how to use the offline slam tracker. Here's some sample code that I wrote based on my understanding of the API. However, it always produces pure rotational transformations that are very close to the identity.

#include "ocean/base/PluginManager.h"
#include "ocean/media/FrameMedium.h"
#include "ocean/media/ImageFileSequence.h"
#include "ocean/media/ImageSequenceFrameProviderInterface.h"
#include "ocean/media/Manager.h"
#include "ocean/media/imageio/ImageIO.h"
#include "ocean/tracking/offline/SLAMTracker.h"

int main(int argc, char **argv) {
  auto tracker = std::make_shared<Ocean::Tracking::Offline::SLAMTracker>();

  Ocean::Media::ImageIO::registerImageIOLibrary();
  Ocean::PluginManager::get().loadPlugins(Ocean::PluginManager::TYPE_MEDIA);

  Ocean::Media::FrameMediumRef frameMedium =
      Ocean::Media::Manager::get().newMedium(
          "./output/C3464225073010_000000.png",
          Ocean::Media::Medium::Type::IMAGE_SEQUENCE, true);
  if (!frameMedium) {
    std::cerr << "no medium" << std::endl;
    Ocean::Media::ImageIO::unregisterImageIOLibrary();
    return -1;
  }

  int width = 960;
  int height = 540;
  float focal_x = 443.7213934872656;
  float focal_y = 443.7213934872656;
  float principal_x = width / 2;
  float principal_y = height / 2;

  Ocean::PinholeCamera pinholeCamera(width, height, focal_x, focal_y,
                                     principal_x, principal_y);

  auto frameProviderInterface = Ocean::CV::FrameProviderInterfaceRef(
      new Ocean::Media::ImageSequenceFrameProviderInterface(frameMedium));

  tracker->setFrameProviderInterface(frameProviderInterface);
  tracker->setTrackingFrameRange(0, 100, 0);
  tracker->setCamera(pinholeCamera, -1, false);
  tracker->setRegionOfInterest(Ocean::CV::SubRegion(0, 0, width, height),
                               false);
  tracker->setAbstractMotionType(Ocean::Tracking::Offline::OfflineTracker::
                                     AbstractMotionType::AMT_COMPLEX);

  tracker->start();
  frameMedium->start();

  while (tracker->running()) {
  }

  tracker->succeeded();

  auto poses = tracker->poses();

  for (const auto &pose : poses) {
    std::cerr << pose.transformation() << std::endl;
  }

  Ocean::Media::ImageIO::unregisterImageIOLibrary();
  return 0;
}

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions