我正在尝试在我的 Ubuntu 16.04(Xenial Xerus)上安装 OpenCV 3.0,但总是出现以下错误。测试还检查 MATLAB。OpenCV 需要 MATLAB 吗?
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES - Failed
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES - Failed
-- Performing Test HAVE_C_WSIGN_PROMO - Failed
-- Performing Test HAVE_C_WNO_DELETE_NON_VIRTUAL_DTOR - Failed
-- Performing Test HAVE_CXX_WNO_UNNAMED_TYPE_TEMPLATE_ARGS
-- Performing Test HAVE_CXX_WNO_UNNAMED_TYPE_TEMPLATE_ARGS - Failed
-- Performing Test HAVE_C_WNO_UNNAMED_TYPE_TEMPLATE_ARGS
-- Performing Test HAVE_C_WNO_UNNAMED_TYPE_TEMPLATE_ARGS - Failed
-- Performing Test HAVE_C_FVISIBILITY_INLINES_HIDDEN - Failed
-- Looking for /home/hanfei/anaconda2/include/libpng/png.h - not found
-- Performing Test HAVE_CXX_WNO_MISLEADING_INDENTATION - Failed
Checking for module 'gstreamer-base-1.0'
-- No package 'gstreamer-base-1.0' found
-- Checking for module 'gstreamer-video-1.0'
-- No package 'gstreamer-video-1.0' found
-- Checking for module 'gstreamer-app-1.0'
-- No package 'gstreamer-app-1.0' found
-- Checking for module 'gstreamer-riff-1.0'
-- No package 'gstreamer-riff-1.0' found
-- Checking for module 'gstreamer-pbutils-1.0'
-- No package 'gstreamer-pbutils-1.0' found
-- Checking for module 'gstreamer-base-0.10'
-- No package 'gstreamer-base-0.10' found
-- Checking for module 'gstreamer-video-0.10'
-- No package 'gstreamer-video-0.10' found
-- Checking for module 'gstreamer-app-0.10'
-- No package 'gstreamer-app-0.10' found
-- Checking for module 'gstreamer-riff-0.10'
-- No package 'gstreamer-riff-0.10' found
-- Checking for module 'gstreamer-pbutils-0.10'
-- No package 'gstreamer-pbutils-0.10' found
-- Checking for module 'libdc1394-2'
-- No package 'libdc1394-2' found
-- Checking for module 'libdc1394'
-- No package 'libdc1394' found
-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - not found
-- Looking for linux/videodev2.h
-- Looking for sys/videoio.h - not found
Checking for module 'libavresample'
-- No package 'libavresample' found
-- Checking for module 'libgphoto2'
-- No package 'libgphoto2' found CMake Error at cmake/OpenCVFindIPP.cmake:243 (include): include could not find load file:
Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
-- Could NOT find Atlas (missing: Atlas_CLAPACK_INCLUDE_DIR)
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
- Could NOT find Matlab (missing: MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN)
-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
答案1
不,它不需要 MATLAB。您可以使用 C++ 和 Python 中的库,我想其他一些语言也可以。我更担心 Atlas 和 BLAS 缺失。这些是非常重要且经过调整的线性代数库,可以执行矩阵向量乘积、矩阵分解和相关运算等操作。
我担心 Atlas 缺失会导致我的代码运行缓慢。因此,我四处寻找并找到了文件 opencv/cmake/OpenCVFindAtlas.cmake。您将在其中看到:
58 set(Atlas_INCLUDE_SEARCH_PATHS
59 /usr/include/atlas
60 /usr/include/atlas-base
61 /usr/include
62 $ENV{Atlas_ROOT_DIR}
63 $ENV{Atlas_ROOT_DIR}/include
64 )
65
66 set(Atlas_LIB_SEARCH_PATHS
67 /usr/lib/atlas
68 /usr/lib/atlas-base
69 $ENV{Atlas_ROOT_DIR}
70 $ENV{Atlas_ROOT_DIR}/lib
71 )
72
73 find_path(Atlas_CBLAS_INCLUDE_DIR NAMES cblas.h PATHS ${Atlas_INCLUDE_SEARCH_PATHS})
74 find_path(Atlas_CLAPACK_INCLUDE_DIR NAMES lapacke.h PATHS ${Atlas_INCLUDE_SEARCH_PATHS})
75
76 find_library(Atlas_CBLAS_LIBRARY NAMES ptcblas_r ptcblas cblas_r cblas PATHS ${Atlas_LIB_SEARCH_PATHS})
77 find_library(Atlas_BLAS_LIBRARY NAMES atlas_r atlas PATHS ${Atlas_LIB_SEARCH_PATHS})
78 find_library(Atlas_LAPACK_LIBRARY NAMES lapack alapack_r alapack lapack_atlas PATHS ${Atlas_LIB_SEARCH_PATHS})
但你不会看到我在第 61 行所做的内容 - 我添加了它。我转到 INCLUDE 和 LIB 搜索路径,然后查找它要查找的头文件和库。我注意到我没有安装 atlas 或 lapack。所以我按照说明安装了 lapack这里。我安装了 Atlas
sudo apt-get install libatlas-base-dev
然后,当我转到 /usr/include 时,我发现了一个名为 atlas-base 的目录。在里面我找到了 cblas.h。不幸的是,lapacke.h 不在那里。那是在 /usr/include 中。因此,我将 /usr/include 添加到 Atlas_INCLUDE_SEARCH_PATHS。然后对于库,我只需验证列出的名称中至少有一个在 lib 搜索路径中。请注意,如果您不知道,库(例如 lapack_atlas)将以前面的“lib”列出。因此 lapack_atlas 将是 liblapack_atlas.so。
为了解决您看到的所有其他错误,我会仔细检查以确保路径设置正确。但您不需要 MATLAB。