在Ubuntu 10.04上安裝openCV很方便:
#apt-get install opencv-doc libcv4 libhighgui4 libcvaux4 libcv-dev libcvaux-dev libhighgui-dev
同時最好順便把ffmpeg的開發文件也裝上。
然後編譯《Learning OpenCV》一書的例子試一把,理論上把Makefile.txt改為Makefile然後make就行,但在我機子上有錯誤:
1. 'cvPyrSegmentation' undeclared identifier
定義在 /usr/local/include/opencv2/legacy/legacy.hpp中,默認沒include進來,把該頭文件包含進來即可。
2. 'cvCalcOpticalFlowHS' undeclared identifier
原因同上,也在legacy.hpp中。
3. cvRand,cvRandInit,cvRandSetRange等函數undeclred identifier
這些函數在 legacy/compat.hpp中,包含進來即可,然後鏈接時還要鏈接libopencv_legacy.so(-lopencv_legacy)。
4. 'CvDTreeParams::CvDTreeParams(...)' undefined reference
鏈接時加-lopencv_ml去鏈接libopencv_ml庫。