簡體   English   中英

如何配置 Makefile 以使用 OpenCV

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM