前言:Ubuntu 12.04, codeblocks 10.05, opencv 2.3 ( 源 163.com, 这个貌似不该声明)
一.安装 CodeBlocks
安装 codeblocks
# apt-get install codeblocks # apt-get install codeblocks-contrib # wxWidgets 貌似要用 # apt-get install libwxbase2.8-dev # 还是 wxWidgets 的东东
二.安装 opencv
1.先查询 opencv :
~# apt-cache search opencv libcv-dev - Translation package for libcv-dev libcv2.3 - computer vision library - libcv* translation package libcvaux-dev - Translation package for libcvaux-dev libcvaux2.3 - computer vision library - libcvaux translation package libhighgui-dev - Translation package for libhighgui-dev libhighgui2.3 - computer vision library - libhighgui translation package libopencv-calib3d-dev - development files for libopencv-calib3d libopencv-calib3d2.3 - computer vision Camera Calibration library libopencv-contrib-dev - development files for libopencv-contrib libopencv-contrib2.3 - computer vision contrib library libopencv-core-dev - development files for libopencv-core libopencv-core2.3 - computer vision core library libopencv-dev - development files for opencv libopencv-features2d-dev - development files for libopencv-features2d libopencv-features2d2.3 - computer vision Feature Detection and Descriptor Extraction library libopencv-flann-dev - development files for libopencv-flann libopencv-flann2.3 - computer vision Clustering and Search in Multi-Dimensional spaces library libopencv-gpu-dev - development files for libopencv-gpu libopencv-gpu2.3 - computer vision GPU Processing library libopencv-highgui-dev - development files for libopencv-highgui libopencv-highgui2.3 - computer vision High-level GUI and Media I/O library libopencv-imgproc-dev - development files for libopencv-imgproc libopencv-imgproc2.3 - computer vision Image Processing library libopencv-legacy-dev - development files for libopencv-legacy libopencv-legacy2.3 - computer vision legacy library libopencv-ml-dev - development files for libopencv-ml libopencv-ml2.3 - computer vision Machine Learning library libopencv-objdetect-dev - development files for libopencv-objdetect libopencv-objdetect2.3 - computer vision Object Detection library libopencv-video-dev - development files for libopencv-video libopencv-video2.3 - computer vision Video analysis library opencv-doc - OpenCV documentation and examples python-opencv - Python bindings for the computer vision library
2.根据查询结果安装
# apt-get install libcv2.3 libcvaux2.3 libhighgui2.3 # apt-get install libcv-dev libcvaux-dev libhighgui-dev
三. codeblocks + opencv 配置
1. 相关文件位置
~# pkg-config --cflags opencv # opencv 头文件(.h) 位置
-I/usr/include/opencv
~# pkg-config --libs opencv # opencv 库文件
-lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann
2. codeBlocks链接库配置: Project -> Build Options 如下图:
3. codeBlocks 头文件目录配置(pkg-config --cflags opencv 结果)
4. CodeBlocks 路文件目录配置
5. 测试结果
四. 程序演示
还没有呢 ....(图片显示不出来,不好意思贴出来,见谅 。。。)
努力查找编码错误后,得出结果( 小鱼终于显示了):
五. 示例代码
#include "cv.h" #include "highgui.h" int main() { IplImage* pImg; pImg = cvLoadImage("/home/nehc/fish.jpg", 1); cvNamedWindow("Image", 1); cvShowImage("Image", pImg); cvWaitKey(0); cvDestroyWindow("Image"); cvReleaseImage(&pImg); return 0; }
...
What is paco ?