------【 2017.07.14 更新 】-------------------------------------------------------
安装 opencv3 每次 cmake 都要下载 3rdparty,下载很慢还总失败。附上自行下载链接及解决办法:
linux 版本 3rdparty 下载地址: https://pan.baidu.com/s/1kVxE6XL
opencv3.2 下载地址: https://pan.baidu.com/s/1dFxQLmp
opencv3.2 也可以去官网下载。
先解压缩 opencv3.2
cd opencv-3.2.0/3rdparty/ippicv
mkdir unpack
然后解压缩 ippicv_linux_20151201.tgz
将解压后的目录 mv 到 unpack 目录中
替换 ippicv 目录中 downloader.cmake 文件内容为:
#
# The script downloads ICV package
#
# On return this will define:
# OPENCV_ICV_PATH - path to unpacked downloaded package
#
function(_icv_downloader)
# Commit SHA in the opencv_3rdparty repo
set(IPPICV_BINARIES_COMMIT "81a676001ca8075ada498583e4166079e5744668")
# Define actual ICV versions
if(APPLE)
set(OPENCV_ICV_PACKAGE_NAME "ippicv_macosx_20151201.tgz")
set(OPENCV_ICV_PACKAGE_HASH "4ff1fde9a7cfdfe7250bfcd8334e0f2f")
set(OPENCV_ICV_PLATFORM "macosx")
set(OPENCV_ICV_PACKAGE_SUBDIR "/ippicv_osx")
elseif(UNIX)
if(ANDROID AND NOT (ANDROID_ABI STREQUAL x86 OR ANDROID_ABI STREQUAL x86_64))
return()
endif()
set(OPENCV_ICV_PACKAGE_NAME "ippicv_linux_20151201.tgz")
set(OPENCV_ICV_PACKAGE_HASH "808b791a6eac9ed78d32a7666804320e")
set(OPENCV_ICV_PLATFORM "linux")
set(OPENCV_ICV_PACKAGE_SUBDIR "/ippicv_lnx")
elseif(WIN32 AND NOT ARM)
set(OPENCV_ICV_PACKAGE_NAME "ippicv_windows_20151201.zip")
set(OPENCV_ICV_PACKAGE_HASH "04e81ce5d0e329c3fbc606ae32cad44d")
set(OPENCV_ICV_PLATFORM "windows")
set(OPENCV_ICV_PACKAGE_SUBDIR "/ippicv_win")
else()
return() # Not supported
endif()
set(OPENCV_ICV_UNPACK_PATH "${CMAKE_CURRENT_LIST_DIR}/unpack")
set(OPENCV_ICV_PATH "${OPENCV_ICV_UNPACK_PATH}${OPENCV_ICV_PACKAGE_SUBDIR}")
message(STATUS "ICV: Package successfully downloaded")
set(OPENCV_ICV_PATH "${OPENCV_ICV_PATH}" PARENT_SCOPE)
endfunction()
_icv_downloader()
然后就可以正常 cmake,make,make install 了
以上内容参考自: http://blog.csdn.net/u011028345/article/details/74568109
提示错误:
** cv2.error: /io/opencv/modules/highgui/src/window.cpp:583: error: (-2) 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 cvShowImage **
这个问题真是。。RLGL。。。
依赖包我就不说了,安装好就是了。特别是 libgtk2.0-dev 和 pkg-config。
简单说一下怎么手动安装 opencv2 吧
点 release
下载 opencv-2.4.13 的 source 源码包
unzip opencv-2.4.13.zip
cd opencv-2.4.13/
cmake -DWITH_GTK=ON -DCMAKE_INSTALL_PREFIX=/usr/local .
make
sudo make install
新安装的 opencv 在 /usr/local/include/ 目录里
这时候找 cv2.so
可能在 /usr/local/lib/python2.7/site-packages/ 目录里
也可能在 /usr/local/lib/python2.7/dist-packages/ 目录里
第一种情况将 cv2.so 复制到 /usr/lib/python2.7/site-packages/ 目录里
第二种情况复制到 /usr/lib/python2.7/dist-packages/ 目录里
好了!!!最坑爹的来了,正常这样操作后就没问题了啊。
如果你运行代码不再提示错误可以无视下面的内容。
还出问题的小伙伴们看一看 /usr/local/lib/python2.7/site-
packages / 或者 /usr/local/lib/python2.7/dist-packages/ 目录下是不是有个名字为 cv2 的文件夹
删掉它!问题就解决了。
来来回回重新安装了一下午的 opencv,崩溃的要死!