博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Installing OpenCV 2.3.1 in Ubuntu
阅读量:5318 次
发布时间:2019-06-14

本文共 2597 字,大约阅读时间需要 8 分钟。

step1:下载

 下载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.1cmake .
 

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

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

你可能感兴趣的文章
Python 发 邮件
查看>>
mysql忘记密码的解决办法
查看>>
全面分析Java的垃圾回收机制2
查看>>
[Code Festival 2017 qual A] C: Palindromic Matrix
查看>>
修改博客园css样式
查看>>
Python3 高阶函数
查看>>
初始面向对象
查看>>
leetcode Letter Combinations of a Phone Number
查看>>
Unity 5.4 测试版本新特性---因吹丝停
查看>>
7.5 文件操作
查看>>
MyEclipse中将普通Java项目convert(转化)为Maven项目
查看>>
node js 安装.node-gyp/8.9.4 权限 无法访问
查看>>
windows基本命令
查看>>
VMware中CentOS设置静态IP
查看>>
[poj1006]Biorhythms
查看>>
Hyper-V虚拟机上安装一个图形界面的Linux系统
查看>>
Hover功能
查看>>
js千分位处理
查看>>
Mac---------三指拖移
查看>>
字符串类型的相互转换
查看>>