Linux下安装OpenCV+Python支持
需要先安装gcc g++一般系统自带
cmake 编译OpenCV时使用,需要手动安装
pkg-config命令,一般系统自带,如果缺少,使用sudo apt-get install pkg-config 安装
NumPy: sudo pip3 install numpy
开始安装opencv
先到官网下载合适的opencv版本
unzip opencv-x.x.x.zip
cd opencv-x.x.x/
cmake -D WITH_GTK_2_X=ON -D CMAKE_INSTALL_PREFIX=/usr/local .
make 或 make -j4 # 表示开4个线程来进行编译
make install
cmake时有可能会出现以下错误
CMake Error at CMakeLists.txt:11 (message):
FATAL: In-source builds are not allowed.
You should create a separate directory for build files.
-- Configuring incomplete, errors occurred!
解决方案:
rm CMakeCache.txt
mkdir build
cd build/
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make / make -j4
make install