标签:需要 配置 opencv read code war .bashrc upd tiff
为了搭建opencv3,看了各种教程,装了卸,卸了装,多次失败后,在几篇文档的借鉴下,终于是成功搭建了环境。
首先,更新ubuntu上的一些库:
sudo apt-get update
sudo apt-get upgrade
其次,需要安装一些搭建opencv3的库(要在opencv3搭建前安装好)
具体需要的库如下:
sudo apt-get install cmake
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev
libavformat-dev libjpeg.dev libtiff4.dev libswscale-dev libjasper-dev
还有一些其他的库是可供选择的,大家可自行搜索。
然后下载opencv3源码:
https://github.com/opencv/opencv/releases
下载、解压完毕,
进入解压目录:
mkdir release
cd release
然后设置cmake编译参数,提供一些可供选择的安装选项,我采用的是:
sudo cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
然后就可以开始编译openCv3了
sudo make
sudo make install
结束后,还需要配置一下环境变量,有很多种方法:
1 sudo gedit /etc/ld.so.conf.d/opencv.conf(可自行创建)
末尾添加一行/usr/local/lib
sudo ldconfig
sudo gedit /etc/bash.bashrc
末尾添加一行
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
2 /etc/bash.bashrc中LD_LIBRARY_PATH加入/usr/local/lib
source /etc/bash.bashrc
3 等等...
然后就可以运行一些例子程序,如:
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main(void)
{
Mat src_image_ = imread("test.jpg");
imshow("src_image_", src_image_);
waitKey(50);
return 0;
}
运行成功说明安装成功。
遇到的错误:
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /home/aborn/software/OpenCV-2.4.1/modules/highgui/src/window.cpp, line 598
terminate called after throwing an instance of ‘cv::Exception‘
具体什么原因没有搞清楚,可能还是没有安装成功,因为它提示的库我分明是安装了的,最后重新装opencv3也就解决问题了。。。没有深究
借鉴链接:
http://blog.csdn.net/leaves_joe/article/details/67656340
http://blog.csdn.net/lanbing510/article/details/41698517
http://blog.csdn.net/yaoweijiao/article/details/51332598
感谢各位博主(泪流满面)!
标签:需要 配置 opencv read code war .bashrc upd tiff
原文地址:http://www.cnblogs.com/dragonyo/p/6754599.html