首先去opencv官网下载源码,选择对的3.4.9版本
安装cmake
xzw@xzw:~/work$ cmake-gui
Command 'cmake-gui' not found, but can be installed with:
xzw@xzw:~/work/opencv-3.4.9/_install$ sudo apt-get install cmake
xzw@xzw:~/work/opencv-3.4.9/_install$ sudo apt install cmake-qt-gui
xzw@xzw:~/work/opencv-3.4.9/_install$ sudo apt-get install libgtk2.0-dev
xzw@xzw:~/work/opencv-3.4.9/_install$ sudo apt-get install pkg-config
解压源码opencv-3.4.9.zip,新建_install文件夹,用于构建项目?
进入_install文件夹输入如下命令,构建项目,在系统目录创建文件夹/usr/local/opencv3.4.9用于安装opencv
xzw@xzw-PC:~/Desktop/opencv-3.4.9/opencv-3.4.9/_install$ sudo cmake -D WITH_FFMPEG=OFF -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/opencv3.4.9 ..
这个过程在下载IPPICV软件包的地方卡了许久,网上许多同学都遇到这个问题了,还有许多妙招,可我太懒,宁愿干等也不想去研究(折腾)。我想大家普遍卡很久,这是个国外的资源吗?所以我连接了翻墙网络,把build目录的东西删掉重新来一遍,差不多喝杯水的功夫真的就搞定了。
xzw@xzw-PC:~/Desktop/opencv-3.4.9/opencv-3.4.9/_install$sudo cmake & sudo cmake install
安装opencv至/usr/local/opencv3.4.9,这个时间会等待很久。
QT使用opencv的问题
terminate called after throwing an instance of 'cv::Exception' ? what(): ?OpenCV(3.4.9) /home/xzw/Desktop/opencv-3.4.9/opencv-3.4.9/modules/highgui/src/window.cpp:641: error: (-2: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 function 'cvNamedWindow'
首先安装?libgtk2.0-dev and pkg-config
sudo apt-get install libgtk2.0-dev pkg-config
之后进入opencv源代码文件夹,进入之前构建的_insall文件夹,执行以下命令
cmake ..
sudo make
sudo make install
|