欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

ubuntu下codeblocks opencv2.4.9配置

程序员文章站 2022-05-21 12:37:25
...

本文只是参考,每个人配置根据opencv与codeblocks安装路径不同而不同。 一.安装 CodeBlocks 安装 codeblocks [plain] view plaincopyprint? #apt-getinstallcodeblocks #apt-getinstallcodeblocks-contrib#wxWidgets貌要用 #apt-getinstalllibwxbase2.8-dev#

本文只是参考,每个人配置根据opencv与codeblocks安装路径不同而不同。

一.安装 CodeBlocks

安装 codeblocks

[plain] view plaincopyprint?

  1. # apt-get install codeblocks
  2. # apt-get install codeblocks-contrib # wxWidgets 貌似要用
  3. # apt-get install libwxbase2.8-dev # 还是 wxWidgets 的东东


二.安装 opencv

1.先查询 opencv :

[plain] view plaincopyprint?

  1. ~# apt-cache search opencv
  2. libcv-dev - Translation package for libcv-dev
  3. libcv2.3 - computer vision library - libcv* translation package
  4. libcvaux-dev - Translation package for libcvaux-dev
  5. libcvaux2.3 - computer vision library - libcvaux translation package
  6. libhighgui-dev - Translation package for libhighgui-dev
  7. libhighgui2.3 - computer vision library - libhighgui translation package
  8. libopencv-calib3d-dev - development files for libopencv-calib3d
  9. libopencv-calib3d2.3 - computer vision Camera Calibration library
  10. libopencv-contrib-dev - development files for libopencv-contrib
  11. libopencv-contrib2.3 - computer vision contrib library
  12. libopencv-core-dev - development files for libopencv-core
  13. libopencv-core2.3 - computer vision core library
  14. libopencv-dev - development files for opencv
  15. libopencv-features2d-dev - development files for libopencv-features2d
  16. libopencv-features2d2.3 - computer vision Feature Detection and Descriptor Extraction library
  17. libopencv-flann-dev - development files for libopencv-flann
  18. libopencv-flann2.3 - computer vision Clustering and Search in Multi-Dimensional spaces library
  19. libopencv-gpu-dev - development files for libopencv-gpu
  20. libopencv-gpu2.3 - computer vision GPU Processing library
  21. libopencv-highgui-dev - development files for libopencv-highgui
  22. libopencv-highgui2.3 - computer vision High-level GUI and Media I/O library
  23. libopencv-imgproc-dev - development files for libopencv-imgproc
  24. libopencv-imgproc2.3 - computer vision Image Processing library
  25. libopencv-legacy-dev - development files for libopencv-legacy
  26. libopencv-legacy2.3 - computer vision legacy library
  27. libopencv-ml-dev - development files for libopencv-ml
  28. libopencv-ml2.3 - computer vision Machine Learning library
  29. libopencv-objdetect-dev - development files for libopencv-objdetect
  30. libopencv-objdetect2.3 - computer vision Object Detection library
  31. libopencv-video-dev - development files for libopencv-video
  32. libopencv-video2.3 - computer vision Video analysis library
  33. opencv-doc - OpenCV documentation and examples
  34. python-opencv - Python bindings for the computer vision library

2.根据查询结果安装

[plain] view plaincopyprint?

  1. # apt-get install libcv2.3 libcvaux2.3 libhighgui2.3
  2. # 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 如下图:

ubuntu下codeblocks opencv2.4.9配置


3. codeBlocks 头文件目录配置(pkg-config --cflags opencv 结果)

ubuntu下codeblocks opencv2.4.9配置


4. CodeBlocks 路文件目录配置

ubuntu下codeblocks opencv2.4.9配置


5. 测试结果

ubuntu下codeblocks opencv2.4.9配置


四. 程序演示

还没有呢 ....(图片显示不出来,不好意思贴出来,见谅 。。。

努力查找编码错误后,得出结果( 小鱼终于显示了):

ubuntu下codeblocks opencv2.4.9配置


五. 示例代码

[cpp] view plaincopyprint?

  1. #include "cv.h"
  2. #include "highgui.h"
  3. int main()
  4. {
  5. IplImage* pImg;
  6. pImg = cvLoadImage("/home/nehc/fish.jpg", 1);
  7. cvNamedWindow("Image", 1);
  8. cvShowImage("Image", pImg);
  9. cvWaitKey(0);
  10. cvDestroyWindow("Image");
  11. cvReleaseImage(&pImg);
  12. return 0;
  13. }