ubuntu 16.04 安装opencv3.3

前端之家收集整理的这篇文章主要介绍了ubuntu 16.04 安装opencv3.3前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

opencv 源文件:https://opencv.org/opencv-3-3.html

安装步骤:

  1. sudo apt-get install build-essential
  2. sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
  3. sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
  4. tar zxf opencv.tar.gz and cd opencv
  5. mkdir build and cd build
  6. cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ../
  7. sudo make
  8. make install

测试用例:


#include <iostream>
#include <stdio.h>
#include <opencv2/opencv.hpp>


using namespace std;
using namespace cv;


int main(int argc,char *argv[])
{
Mat image;
image = imread("./lena.bmp",1);
if( ! image.data)
{
cout<< "No image data" << endl;
return -1;
}
namedWindow("Diaplay Image",WINDOW_AUTOSIZE);
imshow("Display Image",image);
waitKey(0);
return 0;
}

编译命令

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

./lena

原文链接:https://www.f2er.com/ubuntu/350478.html

猜你在找的Ubuntu相关文章