• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
增强的一亩三分地
增强的一亩三分地
博客园          联系   管理     
OpenCV——Install in Linux OS

1. download and install some dependences below first

BRIEF OPERATION

  • [common when you have a stable net invironment]
sudo apt-get install build-essential && sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev && sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
  • [compiler] sudo apt-get install build-essential
  • [required] sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
  • [optional] sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

2. then download opencv3.2.zip && ippicv_linux_20151201.tgz(search on baidu,which will be used soon)

3. make a new folder named ‘build’ and then cd into it

4. run below command to develop and generate

sudo cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..

5. just makesudo make -j4

j4 means make by 4 thread,which can accelarates your process.The number of thread takes from your PC’s hardware.
Maybe you will meet problems when you make,if so,please run a step4-alike command:

sudo cmake -D CMAKE_BUILD_TYPE=RELEASE -D WITH_EIGEN=OFF -DCMAKE_INSTALL_PREFIX = /usr/local/opencv/3.20 ..

6. just make install

sudo make install

7. after those above,you have done all of work in thory.Then you can find and test your mechine by a simple example like shown:

#include <opencv2/opencv.hpp>

using namespace cv;
int main()
{
    Mat srcImage = imread("test.png");
    namedWindow("test");
    imshow("test",srcImage);
    waitKey(0);
    return 0;
}

8.compile and run the test

g++ test.cpp `pkg-config --cflags --libs opencv` -o test 
./test

9.DeError

if you don’t be warning for errors while compiling but running,then you must follow me
//opoen the configuration file
sudo gedit /etc/ld.so.conf
//add a new line
 /usr/loacal/lib
 //update configuration
 sudo ldconfig
 //open an another anyway file
 sudo gedit /etc/bash.bashrc
 //add lines as below following the present part
 PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
    export PKG_CONFIG_PATH
 //then update the contains
 source /etc/bash.bashrc
then you have done what you can do best and your machine can run normally in most cases
posted on 2017-05-09 16:18  -leanard-  阅读(5)  评论(0)    收藏  举报  来源
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3