OpenCV——Install in Linux OS

本文介绍如何在Linux环境下安装并配置OpenCV 3.2,包括依赖库的安装、源码编译及环境变量配置等步骤。通过一个简单的图像显示示例程序验证安装是否成功。

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
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值