我正在尝试编译为 opencv 编写的 Gall 和 Lempitsky 的 Hough 森林实现。
看起来它在查找 opencv 时遇到了问题。我在 ubuntu 上安装了 opencv 2.3.1(或 2.4.4,我不确定)sudo apt-get install libopencv-dev opencv-doc
,我可以编译和运行示例/usr/share/doc/opencv-doc/examples
我更改了make文件路径如下:
# change paths if necessary
# INCLUDES = -I/usr/pack/opencv-1.0.0-dr/amd64-debian-linux4.0/include/opencv
# LIBS = -lcxcore -lcv -lcvaux -lhighgui -lml
# LIBDIRS = -L/usr/pack/opencv-1.0.0-dr/amd64-debian-linux4.0/lib
INCLUDES = -I/usr/include/opencv
LIBS = -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_ts -lopencv_video -lopencv_videostab
LIBDIRS = -L/usr/lib
我运行时遇到的错误make all
是:
g++ -c -I/usr/include/opencv CRForest-Detector.cpp -O3 -Wno-deprecated
CRForest-Detector.cpp: In function ‘void run_train()’:
CRForest-Detector.cpp:543:27: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
CRForest-Detector.cpp: In function ‘void run_detect()’:
CRForest-Detector.cpp:521:27: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
g++ -c -I/usr/include/opencv CRPatch.cpp -O3 -Wno-deprecated
g++ -c -I/usr/include/opencv HoG.cpp -O3 -Wno-deprecated
g++ -c -I/usr/include/opencv CRForestDetector.cpp -O3 -Wno-deprecated
g++ -c -I/usr/include/opencv CRTree.cpp -O3 -Wno-deprecated
g++ -L/usr/lib -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_ts -lopencv_video -lopencv_videostab -o CRForest-Detector CRForest-Detector.o CRPatch.o HoG.o CRForestDetector.o CRTree.o -O3 -Wno-deprecated
CRForest-Detector.o: In function `detect(CRForestDetector&)':
CRForest-Detector.cpp:(.text+0x3340): undefined reference to `cvLoadImage'
CRForest-Detector.cpp:(.text+0x34a3): undefined reference to `cvCreateImage'
CRForest-Detector.cpp:(.text+0x357b): undefined reference to `cvCreateImage'
CRForest-Detector.cpp:(.text+0x35d9): undefined reference to `cvConvertScale'
CRForest-Detector.cpp:(.text+0x3620): undefined reference to `cvSaveImage'
CRForest-Detector.cpp:(.text+0x3634): undefined reference to `cvReleaseImage'
...
我需要更改什么以便 g++ 看到必要的库?如何检查是否安装了所需的库?
编辑:
这是输出pkg-config --modversion opencv
:2.4.4
这是的输出/usr/lib$ ls | grep "opencv"
libopencv_calib3d.a
libopencv_calib3d.so
libopencv_calib3d.so.2.3
libopencv_calib3d.so.2.3.1
libopencv_contrib.a
libopencv_contrib.so
libopencv_contrib.so.2.3
libopencv_contrib.so.2.3.1
libopencv_core.a
libopencv_core.so
libopencv_core.so.2.3
libopencv_core.so.2.3.1
libopencv_features2d.a
libopencv_features2d.so
libopencv_features2d.so.2.3
libopencv_features2d.so.2.3.1
libopencv_flann.a
libopencv_flann.so
libopencv_flann.so.2.3
libopencv_flann.so.2.3.1
libopencv_gpu.a
libopencv_gpu.so
libopencv_gpu.so.2.3
libopencv_gpu.so.2.3.1
libopencv_highgui.a
libopencv_highgui.so
libopencv_highgui.so.2.3
libopencv_highgui.so.2.3.1
libopencv_imgproc.a
libopencv_imgproc.so
libopencv_imgproc.so.2.3
libopencv_imgproc.so.2.3.1
libopencv_legacy.a
libopencv_legacy.so
libopencv_legacy.so.2.3
libopencv_legacy.so.2.3.1
libopencv_ml.a
libopencv_ml.so
libopencv_ml.so.2.3
libopencv_ml.so.2.3.1
libopencv_objdetect.a
libopencv_objdetect.so
libopencv_objdetect.so.2.3
libopencv_objdetect.so.2.3.1
libopencv_video.a
libopencv_video.so
libopencv_video.so.2.3
libopencv_video.so.2.3.1
和输出/usr/include/opencv$ ls | grep ''
cvaux.h
cvaux.hpp
cv.h
cv.hpp
cvwimage.h
cxcore.h
cxcore.hpp
cxeigen.hpp
cxmisc.h
highgui.h
ml.h
是我需要的所有文件还是我遗漏了什么?
编辑2:
按照建议将我的包含和库更改为以下内容:
INCLUDES = -I/usr/include/opencv
LIBS = /usr/lib/libopencv_core.so /usr/lib/libopencv_highgui.so /usr/lib/libopencv_imgproc.so
LIBDIRS = -L/usr/lib
这导致以下输出:
user@user:~/Code/hough_forest$ make clean
rm -f *.o *~ CRForest-Detector
user@user:~/Code/hough_forest$ make all
g++ -c -I/usr/include/opencv CRForest-Detector.cpp -O3 -Wno-deprecated
CRForest-Detector.cpp: In function ‘void run_train()’:
CRForest-Detector.cpp:543:27: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
CRForest-Detector.cpp: In function ‘void run_detect()’:
CRForest-Detector.cpp:521:27: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
g++ -c -I/usr/include/opencv CRPatch.cpp -O3 -Wno-deprecated
g++ -c -I/usr/include/opencv HoG.cpp -O3 -Wno-deprecated
g++ -c -I/usr/include/opencv CRForestDetector.cpp -O3 -Wno-deprecated
g++ -c -I/usr/include/opencv CRTree.cpp -O3 -Wno-deprecated
g++ -L/usr/lib /usr/lib/libopencv_core.so /usr/lib/libopencv_highgui.so /usr/lib/libopencv_imgproc.so -o CRForest-Detector CRForest-Detector.o CRPatch.o HoG.o CRForestDetector.o CRTree.o -O3 -Wno-deprecated
CRForest-Detector.o: In function `detect(CRForestDetector&)':
CRForest-Detector.cpp:(.text+0x3a87): undefined reference to `cvLoadImage'
CRForest-Detector.cpp:(.text+0x3b9e): undefined reference to `cvCreateImage'
CRForest-Detector.cpp:(.text+0x3c61): undefined reference to `cvCreateImage'
CRForest-Detector.cpp:(.text+0x3cae): undefined reference to `cvConvertScale'
CRForest-Detector.cpp:(.text+0x3d03): undefined reference to `cvSaveImage'
CRForest-Detector.cpp:(.text+0x3d12): undefined reference to `cvReleaseImage'
CRForest-Detector.cpp:(.text+0x3d39): undefined reference to `cvReleaseImage'
CRForest-Detector.cpp:(.text+0x3d67): undefined reference to `cvReleaseImage'
...