step1:下载

从http://sourceforge.net/projects/opencvlibrary 下载OpenCV源码,下载文件为OpenCV-2.3.1a.tar.bz2。

cd ~ wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.1/OpenCV-2.3.1a.tar.bz2/download

step2:解压,解压后的文件夹为OpenCV-2.3.1

tar -xvf OpenCV-2.3.1a.tar.bz2
step3:检查配置

cd OpenCV-2.3.1
cmake .

如果结果如图所示,则可进行下一步操作(原来一直不成功,就是因为这一步没有好好做)

step4:编译

make
step5:安装

sudo make install
step6:配置

sudo gedit /etc/ld.so.conf.d/opencv.conf
在打开的文本中输入/usr/local/lib

sudo ldconfig sudo gedit /etc/bash.bashrc
在打开的文件中输入的结尾输入

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH

Let’s check some demos included in OpenCV:

1 cd ~
2 mkdir openCV_samples
3 cp OpenCV-2.1.0/samples/c/* openCV_samples
4 cd openCV_samples/
5 chmod +x build_all.sh
6 ./build_all.sh

Some of the training data for object detection is stored in /usr/local/share/opencv/haarcascades. You need to tell OpenCV which training data to use. I will use one of the frontal face detectors available. Let’s find a face:

1 ./facedetect --cascade="/usr/local/share/opencv/haarcascades/haarcascade_frontalface_alt.xml"--scale=1.5 lena.jpg

Note the scale parameter. It allows you to increase or decrease the size of the smallest object found in the image (faces in this case). Smaller numbers allows OpenCV to find smaller faces, which may lead to increasing the number of false detections. Also, the computation time needed gets larger when searching for smaller objects.

In OpenCV 2.1, the grabcut algorithm is provided in the samples. This is a very nice segmentation algorithm that needs very little user input to segment  the objects in the image. For using the demo, you need to select a rectangle of the area you want to segment. Then, hold the Control key and left click to select the background (in Blue). After that, hold the Shift key and left click to select the foreground (in Red). Then press the n key to generate the segmentation. You can press n again to continue to the next iteration of the algorithm.

1 ./grabcut lena.jpg

This image shows the initial rectangle for defining the object that I want to segment.

Now I roughly set the foreground (red) and background (blue).

When you are ready, press the n key to run the grabcut algorithm. This image shows the result of the first iteration of the algorithm.

Now let’s see some background subtraction from a video. The original video shows a hand moving in front of some trees. OpenCV allows you to separate the foreground (hand) from the background (trees).

1 ./bgfg_segm tree.avi

There are many other samples that you can try.

转载于:https://www.cnblogs.com/windmissing/archive/2012/03/30/2559844.html

Installing OpenCV 2.3.1 in Ubuntu相关推荐

  1. Installing OpenCV 2.4.9 in Ubuntu 14.04 LTS(好文章)

    原文链接 http://www.samontab.com/web/2014/06/installing-opencv-2-4-9-in-ubuntu-14-04-lts/ Installing Ope ...

  2. Installing OpenCV 2.4.9 in Ubuntu 14.04 LTS

    出处:http://www.samontab.com/web/2014/06/installing-opencv-2-4-9-in-ubuntu-14-04-lts/ Term Support ver ...

  3. Installing Node.js and Express on Ubuntu

    Installing Node.js and Express on Ubuntu 1. 在nodejs官网上下载Linux Binaries(已经包含了npm): 2. 安装Node.js 下载后解压 ...

  4. opencv 3.1编译 linux,Ubuntu 编译安装 OpenCV 3.1

    目标系统:Ubuntu 16.04-64bit OpenCV 版本:opencv-3.1.0 安装步骤 安装 cmake.sudo apt-get isntall cmake cmake-qt-gui ...

  5. Zynq7000开发系列-5(OpenCV开发环境搭建:Ubuntu、Zynq)

    操作系统:Ubuntu14.04.5 LTS 64bit OpenCV:OpenCV 3.1.0.opencv_contrib gcc:gcc version 4.8.4 (Ubuntu 4.8.4- ...

  6. opencv python安装 centos_在Ubuntu中安装OpenCV-Python

    和Fedora差不多,Ubuntu安装OpenCV基本上和它是一致的,所以在安装方法上基本上大体相同,有一些不一样的地方我会着重写出来,下面的步骤是在Ubuntu 16.04和18.04(64位)测试 ...

  7. python编写赛车游戏单机版_使用Keras和DDPG玩赛车游戏(自动驾驶)

    为什么选择TORCS游戏 <The Open Racing Car Simulator>(TORCS)是一款开源3D赛车模拟游戏 看着AI学会开车是一件很酷的事 可视化并考察神经网络的学习 ...

  8. 使用Keras和DDPG玩赛车游戏(自动驾驶)

    Using Keras and Deep Deterministic Policy Gradient to play TORCS--300行python代码展示DDPG(基于Keras)--视频 可以 ...

  9. linux中cv调用摄像头,ubuntu中opencv调用摄像头

    ubuntu中opencv调用摄像头 ubuntu中opencv调用摄像头 文章目录 一.Ubuntu中安装opencv 二.关于Linux如何开启摄像头 1.安装VMvareTools,这个是真的强 ...

最新文章

  1. python-django框架中使用docker和elasticsearch配合实现搜索功能
  2. python在化学方面的应用-学材料、化学的要不要担心人工智能抢了自己的饭碗?...
  3. linux高编线程-------线程的创建,终止
  4. 前端学习(2361):下拉刷新的学习
  5. matlab 中 Transform,变换数据存储 - MATLAB transform - MathWorks 中国
  6. Linux netstat命令详解和使用例子(显示各种网络相关信息)
  7. 豆瓣鹅组等7个小组被停用 豆瓣4个月累计关停56个问题小组
  8. 途牛windows转linux,在 Windows 中通过 VirtualBox 启动物理硬盘上的 Linux 操作系统...
  9. ubuntu 14.04下练习lua
  10. jsp操作mysql
  11. python isfile_基于Python中isfile函数和isdir函数使用详解
  12. 佳博打印机驱动安装方法
  13. java 字母金字塔_打印大写字母三角形
  14. 华为遭到英国政府调查。网友: 全世界都在针对华为!
  15. mysql preparing状态_【Docker】在集群中部署应用为什么始终是Preparing状态
  16. 函的红头文件格式制作_浙江省水利厅红头文件函模板范例
  17. 2021-WWW-Learning Intents behind Interactions with Knowledge Graph for Recommendation
  18. vue中v-charts图表数据如何从后台获取?【篇二】
  19. 一张图,了解网站SEO方案
  20. codevs2181 田忌赛马

热门文章

  1. 后端技术:SpringBoot 中实现跨域的5种方式
  2. 程序员幽默:老板让明天带条鱼来大家观察
  3. 一位阿里架构师给每个程序员的小建议
  4. ctrl z撤销后如何恢复_回收站清空后数据如何恢复?
  5. Mysql 多实例multi_mysqld_multi多实例运行
  6. 《Java 高并发》02 多线程的特性
  7. django框架中表单
  8. 可变参数列表(va_list,va_arg,va_copy,va_start,va_end)
  9. 苹果复兴_类型复兴的故事:来自Type West的经验教训
  10. 学习 vuex 源码整体架构,打造属于自己的状态管理库