-
Notifications
You must be signed in to change notification settings - Fork 13
opencv installation ubuntu1504
atinfinity edited this page Sep 19, 2021
·
6 revisions
apt-get
コマンドを用いて各種パッケージをインストールする
sudo apt-get -yV install build-essential
sudo apt-get -yV install cmake
sudo apt-get -yV install libeigen3-dev
sudo apt-get -yV install libgtk2.0-dev
sudo apt-get -yV install libgtkglext1-dev
sudo apt-get -yV install libqt4-dev
sudo apt-get -yV install freeglut3-dev
sudo apt-get -yV install opencl-headers
sudo apt-get -yV install libtbb-dev
sudo apt-get -yV install libjpeg-dev
sudo apt-get -yV install libjasper-dev
sudo apt-get -yV install libpng++-dev
sudo apt-get -yV install libtiff-dev
sudo apt-get -yV install libopenexr-dev
sudo apt-get -yV install libwebp-dev
sudo apt-get -yV install libavcodec-dev
sudo apt-get -yV install libavformat-dev
sudo apt-get -yV install libavutil-dev
sudo apt-get -yV install libswscale-dev
sudo apt-get -yV install libavresample-dev
sudo apt-get -yV install libpython3.4-dev
sudo apt-get -yV install python-numpy python-scipy python-matplotlib
sudo apt-get -yV install python3-numpy python3-scipy python3-matplotlib
https://github.com/opencv/opencv/releases/tag/3.0.0からopencv-3.0.0.tar.gzを入手して展開する
tar xfvz opencv-3.0.0.tar.gz
https://gist.github.com/atinfinity/aa0d4efb98837abd39bbを参考にCMakeを実行してMakefileを生成する
make -j4
sudo make install
sudo ldconfig
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
int main(int argc, const char* argv[])
{
// 画像データをファイルから読み込む
cv::Mat src = cv::imread("lena.jpg", cv::IMREAD_COLOR);
// 画像の読み込みに失敗したらエラー終了する
if(src.empty())
{
std::cerr << "Failed to open image file." << std::endl;
return -1;
}
cv::namedWindow("image", cv::WINDOW_AUTOSIZE);
cv::imshow("image", src);
cv::waitKey(0);
cv::destroyAllWindows();
return 0;
}
g++ test.cpp -I/usr/local/include/opencv2 -I/usr/local/include/opencv -L/usr/local/lib -lopencv_core -lopencv_imgcodecs -lopencv_highgui