日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Installing OpenCV 2.3.1 in Ubuntu

發布時間:2023/12/9 55 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Installing OpenCV 2.3.1 in Ubuntu 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。