Reputation: 69
I am trying to build a ROS package, using catkin build. The package was made to run with OpenCV2, so I installed OpenCV 2.4.9 from source.
I faced some errors when running catkin build. The situation is as following:
At first, I changed the CMakeLists.txt, so that it can locate the right version of OpenCV.
Then, I added #include <vector>
and changed every occurence of vector
to std::vector
in the opencv2/nonfree/features2d.hpp
file, since I was getting the error that vector was not declared and the error disappeared.
Another error I get is:
In file included from /usr/local/include/opencv2/nonfree/nonfree.hpp:46:0,
from /home/vm/catkin_ws/src/ogm_merging/ogm_evaluation/feature_evaluation/include/feature_evaluation/feature_evaluation_metrics/feature_metrics.h:29:
from /home/vm/catkin_ws/src/ogm_merging/ogm_evaluation/feature_evaluation/src/feature_evaluation/feature_evaluation_metrics/feature_metrics.cpp:19:
/usr/local/include/opencv2/nonfree/features2d.hpp:133:5:
error: ‘AlgorithmInfo’ does not name a type
AlgorithmInfo* info() const;
^
The nonfree/features2d.hpp is as following:
#ifndef __OPENCV_NONFREE_FEATURES_2D_HPP__
#define __OPENCV_NONFREE_FEATURES_2D_HPP__
#include "opencv2/features2d/features2d.hpp"
#ifdef __cplusplus
namespace cv
{
/*!
SIFT implementation.
The class implements SIFT algorithm by D. Lowe.
*/
class CV_EXPORTS_W SIFT : public Feature2D
{
public:
CV_WRAP explicit SIFT( int nfeatures=0, int nOctaveLayers=3,
double contrastThreshold=0.04, double edgeThreshold=10,
double sigma=1.6);
//! returns the descriptor size in floats (128)
CV_WRAP int descriptorSize() const;
//! returns the descriptor type
CV_WRAP int descriptorType() const;
//! finds the keypoints using SIFT algorithm
void operator()(InputArray img, InputArray mask,
std::vector<KeyPoint>& keypoints) const;
//! finds the keypoints and computes descriptors for them using SIFT algorithm.
//! Optionally it can compute descriptors for the user-provided keypoints
void operator()(InputArray img, InputArray mask,
std::vector<KeyPoint>& keypoints,
OutputArray descriptors,
bool useProvidedKeypoints=false) const;
AlgorithmInfo* info() const;
void buildGaussianPyramid( const Mat& base, std::vector<Mat>& pyr, int nOctaves ) const;
void buildDoGPyramid( const std::vector<Mat>& pyr, std::vector<Mat>& dogpyr ) const;
void findScaleSpaceExtrema( const std::vector<Mat>& gauss_pyr, const std::vector<Mat>& dog_pyr,
std::vector<KeyPoint>& keypoints ) const;
protected:
void detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
void computeImpl( const Mat& image, std::vector<KeyPoint>& keypoints, Mat& descriptors ) const;
CV_PROP_RW int nfeatures;
CV_PROP_RW int nOctaveLayers;
CV_PROP_RW double contrastThreshold;
CV_PROP_RW double edgeThreshold;
CV_PROP_RW double sigma;
};
typedef SIFT SiftFeatureDetector;
typedef SIFT SiftDescriptorExtractor;
} /* namespace cv */
#endif /* __cplusplus */
#endif
I do not want to change to OpenCV 3 and add the extra modules, as many people in here say, I want to make this run with OpenCV2.
I tried to include files, such as core/core.hpp of features2d/features2d.hpp, but nothing changes.
Where is the AlgorithmInfo
class defined, so that I can use it?
I am using Ubuntu 16.04 and ROS Kinetic.
Update: It worked with Ubuntu 14.04, ROS Indigo and Opencv 2.4, so the problem must be related to ROS or Ubuntu version. Any ideas about it?
Thank you in advance.
Upvotes: 0
Views: 230
Reputation: 7242
ROS and OpenCV works together through opencv_bridge
. I am not sure if this will fix your initial problem, but it looks like you are not using opencv_bridge
which will solve at least some of your problems.
Upvotes: 1