我在RaspberryPi
中安装了opencv并配置了Makefile,但找不到头文件。
如何正确配置Makefile。
我有2个.cpp
个文件和1个.h
个文件。
BlobLabeling.cpp BlobLabeling.h hand_tracking.cpp
当它返回时如下:
pi@raspberrypi ~/test $ make
g++ BlobLabeling.cpp
In file included from BlobLabeling.cpp:2:0:
BlobLabeling.h:9:31: fatal error: highgui/highgui.hpp: No such file or directory
compilation terminated.
Makefile:11: recipe for target 'BlobLabeling.o' failed
make: *** [BlobLabeling.o] Error 1
#include "BlobLabeling.h"
hand_tracking.cpp中的
#include <stdio.h>
#include "cv.h"
#include "highgui.h"
#include "BlobLabeling.h"
BlobLabeling.h中的
#include "highgui/highgui.hpp"
#include "opencv.hpp"
Makefile
CXX = g++
LDFLAGS = -lopencv_legacy -lopencv_highgui -lopencv_core -lopencv_ml -lopencv_video -lopencv_imgproc -lopencv_calib3d -lopencv_objdetect -L/usr/lib
CPPFLAGS = -g -I/usr/include/opencv -I/usr/include/opencv2
all: BlobLabeling.o hand_tracking.o
g++ -o test BlobLabeling.o hand_tracking.o
BlobLabeling.o: BlobLabeling.cpp
g++ BlobLabeling.cpp
hand_tracking.o: hand_tracking.cpp BlobLabeling.h
g++ hand_tracking.cpp
/ usr / include / opencv2 中的
pi@raspberrypi ~/test $ ls /usr/include/opencv2
calib3d features2d imgproc objdetect stitching videostab
contrib flann legacy opencv.hpp ts
core highgui ml photo video
答案 0 :(得分:2)
请使用正确的c ++标题:
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
以及包含路径:
-I/usr/include/opencv2
而不是过时的“cv.h”和“highgui.h”