opencv用に書かれたGallとLempitskyのHough forest実装をコンパイルしようとしています。
こちらの Web サイト [mirrors]からダウンロードできます。
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'
...