使用OpenCV 2.4.9构建ROS包时出现问题
Problem building a ROS package with OpenCV 2.4.9
我正在尝试使用catkin构建构建一个ROS包。这个包是用OpenCV2运行的,所以我从源代码安装了OpenCV2.4.9。
我在运行catkin构建时遇到了一些错误。情况如下:
起初,我更改了CMakeLists.txt,这样它就可以找到正确版本的OpenCV
然后,我添加了#include <vector>
,并将opencv2/nonfree/features2d.hpp
文件中每次出现的vector
更改为std::vector
,因为我得到了未声明矢量的错误,并且错误消失了。
我得到的另一个错误是:
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;
^
非自由/特征2d.hpp如下:
#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
我不想更改为OpenCV3并添加额外的模块,正如这里的许多人所说,我想用OpenCV2运行这个模块。
我尝试包含一些文件,比如features2d/features2d.hpp的core/core.hpp,但没有任何变化。AlgorithmInfo
类在哪里定义,以便我可以使用它?
我使用的是Ubuntu 16.04和ROS Kinetic。
更新:它适用于Ubuntu 14.04、ROS Indigo和Opencv 2.4,所以问题一定与ROS或Ubuntu版本有关。有什么想法吗?
提前谢谢。
opencv_bridge
协同工作。我不确定这是否能解决你最初的问题,但看起来你没有使用opencv_bridge
,它至少能解决你的一些问题。
相关文章:
- 接受函数在发送数据包时等待
- 尝试使用 RTool 在 R4.0 上安装软件包时出现编译错误
- 使用jsoncpp-NuGet包时获取未解析的外部符号
- 当模板类使用参数包时,如何传递其他模板参数
- 我的代码在创建楼梯图案时出了什么问题
- wcslen() 在使用编译指示包时返回不正确的结果
- 在 Cloud9 上安装 AWS C++ 开发工具包时出现问题
- 在 R 中安装"RcppArmadillo"包时出错
- vcpkg 在安装软件包时找不到 cmake.cmd
- 定位包时未设置QT的Cmake Dragndrop框架
- 使用RCPP包创建R包时出错:macOS中的dyn.load中出错
- 通过 Conan 安装仅标头包时出错
- 在 lambda 中捕获参数包时,某些整数会丢失其值
- 使用RCPP与外部C 库构建R软件包时未定义的参考
- -O2 优化不会在读取大文件时出圈
- 使用OpenCV 2.4.9构建ROS包时出现问题
- SFML 套接字 发送数据包时设置为 sf::套接字::错误
- MySQL Windows c api 命名管道错误:"在'等待初始通信数据包'时丢失与 MySQL 服务器的连接,系统错误:0
- LNK1120在构建引用 Boost 的 Python 包时
- 使用 TDM-GCC-64、Cmake 和 CodeBlock 在 Windows 8 中构建 OpenCV 静态库时出