• Installing OpenCV 2.3.1 in Ubuntu


    step1:下载

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


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


    step3:检查配置

    
    

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

    configuring opencv2.1

    step4:编译


    step5:安装


    step6:配置


    在打开的文本中输入/usr/local/lib


    在打开的文件中输入的结尾输入

    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.

  • 相关阅读:
    C#&.Net干货分享-构造QRCoderHelper生成二维码图片
    C#&.Net干货分享- 构造BaiduLanguageHelper对接百度的语言翻译
    C#&.Net干货分享- 构建Spire-Office相关Helper操作Word、Excel、PDF等
    C#后台架构师成长之路-Orm篇体系
    C#后台架构师成长之路-进阶体系篇章大纲
    C#后台架构师成长之路-基础体系篇章大纲
    统一删除SQL Server某一个数据库内批量表数据
    SQL Server 创建链接服务器的脚本,自定义链路服务器的简短名称
    SQL SERVER查询数据库所有表的大小,按照记录数降序排列
    一键删除数据库所有的外键约束-FOREIGN_KEYS
  • 原文地址:https://www.cnblogs.com/windmissing/p/2559844.html
Copyright © 2020-2023  润新知