我一直在另一台电脑上做本教程,现在,回到家后,我似乎不能再运行代码了。
我不断收到类似于以下错误的错误:
g++-4.8 -I/usr/local/include/opencv -I/usr/lib/i386-linux-gnu/ -I/usr/local/include/opencv2 -O2 -g -Wall -c -fmessage-length=0 -MMD -MP -MF"image-processor/references/homography.d" -MT"image-processor/references/homography.d" -o "image-processor/references/homography.o" "../image-processor/references/homography.cpp"
In file included from /usr/include/opencv2/nonfree/nonfree.hpp:46:0,
from ../image-processor/references/homography.cpp:10:
/usr/include/opencv2/nonfree/features2d.hpp:73:21: error: ‘vector’ has not been declared
vector<KeyPoint>& keypoints) const;
^
/usr/include/opencv2/nonfree/features2d.hpp:73:27: error: expected ‘,’ or ‘...’ before ‘<’ token
vector<KeyPoint>& keypoints) const;
^
/usr/include/opencv2/nonfree/features2d.hpp:77:21: error: ‘vector’ has not been declared
vector<KeyPoint>& keypoints,
^
/usr/include/opencv2/nonfree/features2d.hpp:77:27: error: expected ‘,’ or ‘...’ before ‘<’ token
vector<KeyPoint>& keypoints,
^
/usr/include/opencv2/nonfree/features2d.hpp:76:10: error: ‘void cv::SIFT::operator()(cv::InputArray, cv::InputArray, int) const’ cannot be overloaded
void operator()(InputArray img, InputArray mask,
^
/usr/include/opencv2/nonfree/features2d.hpp:72:10: error: with ‘void cv::SIFT::operator()(cv::InputArray, cv::InputArray, int) const’
void operator()(InputArray img, InputArray mask,
^
/usr/include/opencv2/nonfree/features2d.hpp:81:5: error: ‘AlgorithmInfo’ does not name a type
AlgorithmInfo* info() const;
^
/usr/include/opencv2/nonfree/features2d.hpp:83:49: error: ‘vector’ has not been declared
void buildGaussianPyramid( const Mat& base, vector<Mat>& pyr, int nOctaves ) const;
^
/usr/include/opencv2/nonfree/features2d.hpp:83:55: error: expected ‘,’ or ‘...’ before ‘<’ token
void buildGaussianPyramid( const Mat& base, vector<Mat>& pyr, int nOctaves ) const;
^
/usr/include/opencv2/nonfree/features2d.hpp:84:33: error: ‘vector’ does not name a type
void buildDoGPyramid( const vector<Mat>& pyr, vector<Mat>& dogpyr ) const;
^
/usr/include/opencv2/nonfree/features2d.hpp:84:39: error: expected ‘,’ or ‘...’ before ‘<’ token
void buildDoGPyramid( const vector<Mat>& pyr, vector<Mat>& dogpyr ) const;
^
/usr/include/opencv2/nonfree/features2d.hpp:85:39: error: ‘vector’ does not name a type
void findScaleSpaceExtrema( const vector<Mat>& gauss_pyr, const vector<Mat>& dog_pyr,
^
/usr/include/opencv2/nonfree/features2d.hpp:85:45: error: expected ‘,’ or ‘...’ before ‘<’ token
void findScaleSpaceExtrema( const vector<Mat>& gauss_pyr, const vector<Mat>& dog_pyr,
^
/usr/include/opencv2/nonfree/features2d.hpp:89:40: error: ‘vector’ has not been declared
void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
^
/usr/include/opencv2/nonfree/features2d.hpp:89:46: error: expected ‘,’ or ‘...’ before ‘<’ token
void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
^
/usr/include/opencv2/nonfree/features2d.hpp:90:41: error: ‘vector’ has not been declared
void computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const;
^
/usr/include/opencv2/nonfree/features2d.hpp:90:47: error: expected ‘,’ or ‘...’ before ‘<’ token
void computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const;
^
/usr/include/opencv2/nonfree/features2d.hpp:125:28: error: ‘vector’ has not been declared
CV_OUT vector<KeyPoint>& keypoints) const;
^
/usr/include/opencv2/nonfree/features2d.hpp:125:34: error: expected ‘,’ or ‘...’ before ‘<’ token
CV_OUT vector<KeyPoint>& keypoints) const;
^
In file included from /usr/include/opencv2/nonfree/nonfree.hpp:46:0,
from ../image-processor/references/homography.cpp:10:
/usr/include/opencv2/nonfree/features2d.hpp:128:28: error: ‘vector’ has not been declared
CV_OUT vector<KeyPoint>& keypoints,
^
/usr/include/opencv2/nonfree/features2d.hpp:128:34: error: expected ‘,’ or ‘...’ before ‘<’ token
CV_OUT vector<KeyPoint>& keypoints,
^
/usr/include/opencv2/nonfree/features2d.hpp:127:10: error: ‘void cv::SURF::operator()(cv::InputArray, cv::InputArray, int) const’ cannot be overloaded
void operator()(InputArray img, InputArray mask,
^
In file included from /usr/include/opencv2/nonfree/nonfree.hpp:46:0,
from ../image-processor/references/homography.cpp:10:
/usr/include/opencv2/nonfree/features2d.hpp:124:10: error: with ‘void cv::SURF::operator()(cv::InputArray, cv::InputArray, int) const’
void operator()(InputArray img, InputArray mask,
^
In file included from /usr/include/opencv2/nonfree/nonfree.hpp:46:0,
from ../image-processor/references/homography.cpp:10:
/usr/include/opencv2/nonfree/features2d.hpp:132:5: error: ‘AlgorithmInfo’ does not name a type
AlgorithmInfo* info() const;
^
/usr/include/opencv2/nonfree/features2d.hpp:142:40: error: ‘vector’ has not been declared
void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
^
/usr/include/opencv2/nonfree/features2d.hpp:142:46: error: expected ‘,’ or ‘...’ before ‘<’ token
void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
^
/usr/include/opencv2/nonfree/features2d.hpp:143:41: error: ‘vector’ has not been declared
void computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const;
^
/usr/include/opencv2/nonfree/features2d.hpp:143:47: error: expected ‘,’ or ‘...’ before ‘<’ token
void computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const;
^
../image-processor/references/homography.cpp: In function ‘int main(int, char**)’:
../image-processor/references/homography.cpp:83:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for( int i = 0; i < good_matches.size(); i++ )
^
../image-processor/references/homography.cpp:108:24: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
char* image_window = "Window";
^
make: *** [image-processor/references/homography.o] Error 1
**** Build Finished ****
我做了很多研究,做了以下工作:
下面是Eclipse创建和使用的makefile:
自动生成的文件。不要编辑! # -include ../makefile.init RM := rm 参与构建的所有源都在这里定义。 -include sources.mk -include图像处理器/src/ subdir.mk -include图像处理器/references/subdir.mk -include subdir.mk -include objects.mk ifneq ($(MAKECMDGOALS),clean) ifneq ( $(C++_DEPS)),-include $(C++_DEPS) endif ifneq ( $(C_DEPS)),-include $(C_DEPS) endif ifneq ($(剥$(CC_DEPS)),-include $(CC_DEPS) endif ifneq ($(strip $(CPP_DEPS)),) -include $(CPP_DEPS) endif ifneq ($(剥$(CXX_DEPS),) -include $(CXX_DEPS) endif ifneq ($(strip $(C_UPPER_DEPS)),-include $(C_UPPER_DEPS) endif endif -include ./makefile.defs 将这些工具调用的输入和输出添加到构建变量中。 所有目标:共享机器人视觉 工具调用共享-机器人视觉:$(OBJS) $(USER_OBJS) @echo“构建目标:$@‘@echo’调用: GCC C++ Linker‘g++ -L/usr/lib/i 386-linux-gnu/ -L/usr/local/include/opencv 2 -o 其他目标清除:$(OBJS)$(C++_DEPS)$(C_DEPS)$(CC_DEPS)$(CPP_DEPS)$(EXECUTABLES)$(CXX_DEPS)$(C_UPPER_DEPS) -$(RM) 共享-机器人视觉-@echo‘’ .PHONY:所有干净的受抚养人.SECONDARY: -include ./makefile.Target
以下是我所包括的图书馆:
USER_OBJS := LIBS := -lopencv_core -lopencv_xfeatures2d -lopencv_nonfree -lopencv_flann -lopencv_legacy -lopencv_contrib -lopencv_objdetect -lopencv_calib3d -lopencv_features2d -lopencv_imgcodecs -lopencv_imgproc -lopencv_video -lopencv_ml -lopencv_ts -lopencv_videostab -lopencv_highgui -lopencv_highgui-lopencv_ts-lopencv_videostab-lopencv_ml-lopencv_ts-lopencv_videostab-lopencv_videostab-lopencv_highgui -lopencv_imgproc
编辑:
我的标题:
#include <stdio.h>
#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/opencv_modules.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include <opencv2/nonfree/nonfree.hpp>
#include <opencv2/nonfree/features2d.hpp>
using namespace cv;
using namespace std;
发布于 2015-05-05 22:29:45
要运行该示例,您需要以下库
-lopencv_core
-lopencv_highgui
-lopencv_features2d
-lopencv_nonfree
-lopencv_flann
-lopencv_calib3d
因此,现在您需要告诉编译器头文件在哪里。
-I/.../opencv-2.4.10/install/include
因此,现在您需要告诉链接器库文件在哪里。
-L/.../opencv-2.4.10/release/lib
调用g++
编译器
g++ main.cpp -o test -I/.../opencv-2.4.10/install/include -L/.../opencv-2.4.10/release/lib -lopencv_core -lopencv_highgui -lopencv_features2d -lopencv_nonfree -lopencv_flann -lopencv_calib3d
我使用的是ubuntu和opencv 2.4.10。样品运行得很好。
https://stackoverflow.com/questions/30063183
复制相似问题