ubuntu安装OpenCV 3.4.0及遇到的问题

  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. mkdir -p opencv-3.4.0 build
  4. cd opencv-3.4.0/build
  5. cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_CUDA=ON -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D BUILD_EXAMPLES=ON -D WITH_OPENGL=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1 -D WITH_NVCUVID:BOOL=”1” -D WITH_GSTREAMER=ON -D WITH_FFMPEG=ON -D WITH_QT=ON ..
    :在cmake时会去下载dnn模块的人脸模型,10M多点,不过下载速度比较慢,如果你之前下载过,可直接将模型 res10_300x300_ssd_iter_140000.caffemodel复制到文件夹xx/opencv-3.4.0/samples/dnn/face_detector/中。
  6. make -j6//(run 6 jobs in parallel,但最好不要超过cpu核数,不然可能会出现错误)
    :本人在make时会遇到C++内部错误,不用管它,再次make可继续编译,具体原因不知
  7. sudo make install
  8. 在执行imshow函数时,出现如下error
    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 cvShowImage, file /home/nvidia/Documents/opencv-3.4.0/modules/highgui/src/window.cpp, line 611 terminate called after throwing an instance of cv::Exception
    解决方法:在cmake时加入-D WITH_QT=ON 选项
  9. 在-D WITH_QT=ON 编译时,出现如下error
    error: #error Please include the appropriate gl headers before including cuda_gl_interop.h
    解决办法:修改文件/usr/local/cuda-8.0/targets/aarch64-linux/include/cuda_gl_interop.h如下,注释掉第8-12及第14行即可
7.#else /* __APPLE__ */
8.//#if defined(__arm__) || defined(__aarch64__)
9.//#ifndef GL_VERSION
10.//#error Please include the appropriate gl headers before including cuda_gl_interop.h
11.//#endif
12.//#else
13.#include <GL/gl.h>
14.//#endif
15.#endif /* __APPLE__ */

猜你喜欢

转载自blog.csdn.net/u013187057/article/details/80112705