您的位置:首页 > 运维架构 > Linux

OpenCV——Install in Linux OS

2017-05-09 16:18 330 查看

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 make
sudo 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

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: