Ask Your Question

Revision history [back]

What does the following code do?

I'm trying to compile the lsd_slam_noros package located at :

This package depends on a number of other works such as

  1. openFABmap at
  2. g2o at
  3. OpenCV (ofcourse!)

So far I have encountered various different errors and resolved them using information from the internet (google/stackoverflow/answers_opencv). Now I am stuck at this particular error of conflicting declaration

In file included from /usr/local/include/opencv2/features2d/features2d.hpp:48:0,
                 from /home/pp/June/Milestones/lsd_slam_noros-master/thirdparty/openFabMap/include/bowmsctrainer.hpp:6,
                 from /home/pp/June/Milestones/lsd_slam_noros-master/thirdparty/openFabMap/include/openfabmap.hpp:7,
                 from /home/pp/June/Milestones/lsd_slam_noros-master/lsd_slam/global_mapping/
/usr/local/include/opencv2/features2d.hpp:231:19: error: conflicting declaration ‘typedef class cv::Feature2D cv::FeatureDetector’
 typedef Feature2D FeatureDetector;
In file included from /home/pp/June/Milestones/lsd_slam_noros-master/lsd_slam/global_mapping/
/home/pp/June/Milestones/lsd_slam_noros-master/global_mapping/fab_map.h:10:7: note: previous declaration as ‘class cv::FeatureDetector’
 class FeatureDetector;

I am able to compile the openFABmap package without any errors.
When compiling the lsd_slam module I am getting the declaration conflict error. I think the error is due to wrong usage in

I looked in to the source of file fab_map.hpp and it contains the following code :

#pragma once
#include <opencv2/core/core.hpp>

namespace of2 {
class FabMap;
namespace cv {
    class FeatureDetector;
    class BOWImgDescriptorExtractor;

namespace lsd_slam

class Frame;

/** Interface to openFabMap. */
class FabMap
    /** Initializes FabMap. */

    /** Writes out the confusion matrix if enabled. */

    /** Adds the keyframe to the set of frames to compare against and returns
     *  its (non-negative) ID in FabMap (different to the keyframe ID).
     *  Returns -1 if the frame cannot be added due to an error. */
//  int add(KeyFrame* keyframe);

    /** Checks if the keyframe is determined to be the same as an already
     *  added frame and if yes, returns its ID. If not, returns -1.
     *  Does not directly return a KeyFrame pointer to allow for KeyFrames
     *  being deleted. */
//  int compare(KeyFrame* keyframe);

    /** Combination of compare() followed by add() (more efficient). */
    void compareAndAdd(Frame* keyframe, int* out_newID, int* out_loopID);

    /** Returns if the class is initialized correctly (i.e. if the required
     *  files could be loaded). */
    bool isValid() const;

    int nextImageID;
    cv::Ptr<cv::FeatureDetector> detector;
    cv::Ptr<cv::BOWImgDescriptorExtractor> bide;
    cv::Ptr<of2::FabMap> fabMap;

    bool printConfusionMatrix;
    cv::Mat confusionMat;

    bool valid;


In line 8, above code tries to re-define the namespace cv with the two class that supposedly belong to feature2D module ? I am having difficulty understanding this code as I have not worked much with C++. I am ok with C though.

Kindly help me in resolving the error and compiling the package !