Program Listing for File fractaldetector.h

Return to documentation for file (include/aruco/fractaldetector.h)

#ifndef _ARUCO_FractalDetector_H
#define _ARUCO_FractalDetector_H

#include "markerdetector.h"
#include "fractallabelers/fractallabeler.h"
#include "aruco_export.h"
namespace aruco
{
class ARUCO_EXPORT FractalDetector
{
  struct ARUCO_EXPORT Params
  {
    std::string configuration_type;
  };

public:
  FractalDetector();

  void setConfiguration(int configuration);

  void setConfiguration(std::string configuration);

  void setParams(const CameraParameters &cam_params, float markerSize)
  {
    _cam_params = cam_params;

    Tracker.setParams(cam_params, _fractalLabeler->_fractalMarkerSet, markerSize);
  }

  // return fractalmarkerset
  FractalMarkerSet getConfiguration()
  {
    return Tracker.getFractal();
  }

  // return true if any marker is detected, false otherwise
  bool detect(const cv::Mat &input)
  {
    Markers = _markerDetector->detect(input);

    if (Markers.size() > 0)
      return true;
    else
      return false;
  }

  // return true if the pose is estimated, false otherwise
  bool poseEstimation()
  {
    if (_cam_params.isValid())
    {
      return Tracker.fractalInnerPose(_markerDetector, Markers);
    }
    else
      return false;
  }

  // return the rotation vector. Returns an empty matrix if last call to estimatePose returned false
  cv::Mat getRvec()
  {
    return Tracker.getRvec();
  }
  // return the translation vector. Returns an empty matrix if last call to estimatePose returned false
  cv::Mat getTvec()
  {
    return Tracker.getTvec();
  }

  void drawImage(cv::Mat &img, cv::Mat &img2);

  // draw borders of markers
  void drawMarkers(cv::Mat &img);

  // draw inner corners of markers
  void draw2d(cv::Mat &img);

  // draw pose estimation axes
  void draw3d(cv::Mat &img, bool cube = true, bool axis = true);

  // draw marker as cube
  void draw3dCube(cv::Mat &Image, FractalMarker m, const CameraParameters &CP, int lineSize);

  // return detected markers
  std::vector<Marker> getMarkers()
  {
    return Markers;
  }

  // return image pyramid
  std::vector<cv::Mat> getImagePyramid()
  {
    return _markerDetector->getImagePyramid();
  }

private:
  std::vector<aruco::Marker> Markers;  // detected markers
  FractalPoseTracker Tracker;
  Params _params;
  CameraParameters _cam_params;  // Camera parameters
  cv::Ptr<FractalMarkerLabeler> _fractalLabeler;
  cv::Ptr<MarkerDetector> _markerDetector;
};
}  // namespace aruco
#endif