[英]How to configure Makefile to use OpenCV
我在RaspberryPi中安装了opencv并配置了Makefile但找不到头文件。 如何正确配置Makefile?
我有 2 个.cpp
文件和 1 个.h
文件。
BlobLabeling.cpp BlobLabeling.h hand_tracking.cpp
当我运行 make 时,它返回以下内容:
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
在 BlobLabeling.cpp 中
#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"
生成文件
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
请使用正确的 C++ 头文件:
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
连同包含路径:
-I/usr/include/opencv2
而不是过时的“cv.h”和“highgui.h”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.