好的,所以我一直在寻找这个问题,我仍然对如何解决这个问题一无所知。
我正在尝试运行此处提供的示例代码:http://docs.opencv.org/trunk/d1/dc5/tutorial_background_subtraction.html。
我理解代码。我只是无法编译!问题出在库包含。这是我的Makefile
:
CFLAGS = `pkg-config --cflags opencv`
LIBS = `pkg-config --libs opencv`
% : %.cpp
g++ $(CFLAGS) $(LIBS) -o $@ $<
这是错误:
prakhar@inS4n3 ~/dev/gender recognition $ make bs
g++ `pkg-config --cflags opencv` `pkg-config --libs opencv` -o bs bs.cpp
bs.cpp:2:33: fatal error: opencv2/imgcodecs.hpp: No such file or directory
#include "opencv2/imgcodecs.hpp"
^
compilation terminated.
Makefile:5: recipe for target 'bs' failed
make: *** [bs] Error 1
如果我(暂时)注释掉此文件,我会收到imgproc.hpp
的类似错误。在我的另一个OpenCV
代码中,以下编译完全:
#include "opencv2/core/core.hpp"
#include "opencv2/contrib/contrib.hpp"
#include "opencv2/highgui/highgui.hpp"
据我所知,将opencv2/core.hpp
替换为opencv2/core/core.hpp
或将opencv2/imgproc.hpp
替换为opencv2/imgproc/imgproc.hpp
可以完成这项工作。
所以我看得更深,这里是我的opencv2
文件夹:
prakhar@inS4n3 /usr/include/opencv2 $ ll
total 84
drwxr-xr-x 2 root root 4096 Nov 14 19:42 calib3d
drwxr-xr-x 2 root root 4096 Nov 14 19:42 contrib
drwxr-xr-x 2 root root 4096 Nov 14 19:42 core
drwxr-xr-x 2 root root 4096 Nov 14 19:42 features2d
drwxr-xr-x 2 root root 4096 Nov 14 19:42 flann
drwxr-xr-x 3 root root 4096 Nov 14 19:42 gpu
drwxr-xr-x 2 root root 4096 Nov 14 19:42 highgui
drwxr-xr-x 2 root root 4096 Nov 14 19:42 imgproc
drwxr-xr-x 2 root root 4096 Nov 14 19:42 legacy
drwxr-xr-x 2 root root 4096 Nov 14 19:42 ml
drwxr-xr-x 2 root root 4096 Nov 14 19:42 nonfree
drwxr-xr-x 2 root root 4096 Nov 14 19:42 objdetect
drwxr-xr-x 2 root root 4096 Nov 14 19:42 ocl
-rw-r--r-- 1 root root 2751 Oct 1 2014 opencv.hpp
-rw-r--r-- 1 root root 672 Nov 12 00:02 opencv_modules.hpp
drwxr-xr-x 2 root root 4096 Nov 14 19:42 photo
drwxr-xr-x 3 root root 4096 Nov 14 19:42 stitching
drwxr-xr-x 2 root root 4096 Nov 14 19:42 superres
drwxr-xr-x 2 root root 4096 Nov 14 19:42 ts
drwxr-xr-x 2 root root 4096 Nov 14 19:42 video
drwxr-xr-x 2 root root 4096 Nov 14 19:42 videostab
任何人都可以告诉我为什么会这样,我如何获得imgcodecs.hpp
和videoio.hpp
模块?
我在Arch Linux上使用OpenCV
2.4.10-2
。