Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';t为Python 2.7构建OpenCV3.1_Python_Python 2.7_Opencv - Fatal编程技术网

Can';t为Python 2.7构建OpenCV3.1

Can';t为Python 2.7构建OpenCV3.1,python,python-2.7,opencv,Python,Python 2.7,Opencv,我按照此处的教程下载了opencv和opencv contrib文件: 我想在名为obj_recog的Conda环境中安装OpenCV3 for Python2.7。我的操作系统是Ubuntu 16.04。 然后,我尝试使用不同的选项运行Cmake,最终解决了以下问题: cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local \ -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=

我按照此处的教程下载了opencv和opencv contrib文件:

我想在名为obj_recog的Conda环境中安装OpenCV3 for Python2.7。我的操作系统是Ubuntu 16.04。 然后,我尝试使用不同的选项运行Cmake,最终解决了以下问题:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON \
-D WITH_QT=ON -D WITH_GTK=ON -D WITH_OPENGL=ON -D WITH_CUDA=ON \
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 -D WITH_FFMPEG=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.1.0/modules \
-D PYTHON_EXECUTABLE=~/anaconda3/envs/obj_recog/bin/python \
-D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF \
-D BUILD_EXAMPLES=ON -D WITH_CUBLAS=ON ..
以下是我得到的输出:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_GTK=ON -D WITH_OPENGL=ON -D WITH_CUDA=ON -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 -D WITH_FFMPEG=ON -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.1.0/modules -D PYTHON_EXECUTABLE=~/anaconda3/envs/obj_recog/bin/python -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF -D BUILD_EXAMPLES=ON -D WITH_CUBLAS=ON ..
-- The CXX compiler identification is GNU 5.4.0
-- The C compiler identification is GNU 5.4.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Detected version of GNU GCC: 54 (504)
-- Performing Test HAVE_CXX_FSIGNED_CHAR
-- Performing Test HAVE_CXX_FSIGNED_CHAR - Success
-- Performing Test HAVE_C_FSIGNED_CHAR
-- Performing Test HAVE_C_FSIGNED_CHAR - Success
-- Performing Test HAVE_CXX_W
-- Performing Test HAVE_CXX_W - Success
-- Performing Test HAVE_C_W
-- Performing Test HAVE_C_W - Success
-- Performing Test HAVE_CXX_WALL
-- Performing Test HAVE_CXX_WALL - Success
-- Performing Test HAVE_C_WALL
-- Performing Test HAVE_C_WALL - Success
-- Performing Test HAVE_CXX_WERROR_RETURN_TYPE
-- Performing Test HAVE_CXX_WERROR_RETURN_TYPE - Success
-- Performing Test HAVE_C_WERROR_RETURN_TYPE
-- Performing Test HAVE_C_WERROR_RETURN_TYPE - Success
-- Performing Test HAVE_CXX_WERROR_NON_VIRTUAL_DTOR
-- Performing Test HAVE_CXX_WERROR_NON_VIRTUAL_DTOR - Success
-- Performing Test HAVE_C_WERROR_NON_VIRTUAL_DTOR
-- Performing Test HAVE_C_WERROR_NON_VIRTUAL_DTOR - Success
-- Performing Test HAVE_CXX_WERROR_ADDRESS
-- Performing Test HAVE_CXX_WERROR_ADDRESS - Success
-- Performing Test HAVE_C_WERROR_ADDRESS
-- Performing Test HAVE_C_WERROR_ADDRESS - Success
-- Performing Test HAVE_CXX_WERROR_SEQUENCE_POINT
-- Performing Test HAVE_CXX_WERROR_SEQUENCE_POINT - Success
-- Performing Test HAVE_C_WERROR_SEQUENCE_POINT
-- Performing Test HAVE_C_WERROR_SEQUENCE_POINT - Success
-- Performing Test HAVE_CXX_WFORMAT
-- Performing Test HAVE_CXX_WFORMAT - Success
-- Performing Test HAVE_C_WFORMAT
-- Performing Test HAVE_C_WFORMAT - Success
-- Performing Test HAVE_CXX_WERROR_FORMAT_SECURITY
-- Performing Test HAVE_CXX_WERROR_FORMAT_SECURITY - Success
-- Performing Test HAVE_C_WERROR_FORMAT_SECURITY
-- Performing Test HAVE_C_WERROR_FORMAT_SECURITY - Success
-- Performing Test HAVE_CXX_WMISSING_DECLARATIONS
-- Performing Test HAVE_CXX_WMISSING_DECLARATIONS - Success
-- Performing Test HAVE_C_WMISSING_DECLARATIONS
-- Performing Test HAVE_C_WMISSING_DECLARATIONS - Success
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES - Failed
-- Performing Test HAVE_C_WMISSING_PROTOTYPES
-- Performing Test HAVE_C_WMISSING_PROTOTYPES - Success
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES - Failed
-- Performing Test HAVE_C_WSTRICT_PROTOTYPES
-- Performing Test HAVE_C_WSTRICT_PROTOTYPES - Success
-- Performing Test HAVE_CXX_WUNDEF
-- Performing Test HAVE_CXX_WUNDEF - Success
-- Performing Test HAVE_C_WUNDEF
-- Performing Test HAVE_C_WUNDEF - Success
-- Performing Test HAVE_CXX_WINIT_SELF
-- Performing Test HAVE_CXX_WINIT_SELF - Success
-- Performing Test HAVE_C_WINIT_SELF
-- Performing Test HAVE_C_WINIT_SELF - Success
-- Performing Test HAVE_CXX_WPOINTER_ARITH
-- Performing Test HAVE_CXX_WPOINTER_ARITH - Success
-- Performing Test HAVE_C_WPOINTER_ARITH
-- Performing Test HAVE_C_WPOINTER_ARITH - Success
-- Performing Test HAVE_CXX_WSHADOW
-- Performing Test HAVE_CXX_WSHADOW - Success
-- Performing Test HAVE_C_WSHADOW
-- Performing Test HAVE_C_WSHADOW - Success
-- Performing Test HAVE_CXX_WSIGN_PROMO
-- Performing Test HAVE_CXX_WSIGN_PROMO - Success
-- Performing Test HAVE_C_WSIGN_PROMO
-- Performing Test HAVE_C_WSIGN_PROMO - Failed
-- Performing Test HAVE_CXX_WNO_NARROWING
-- Performing Test HAVE_CXX_WNO_NARROWING - Success
-- Performing Test HAVE_C_WNO_NARROWING
-- Performing Test HAVE_C_WNO_NARROWING - Success
-- Performing Test HAVE_CXX_WNO_DELETE_NON_VIRTUAL_DTOR
-- Performing Test HAVE_CXX_WNO_DELETE_NON_VIRTUAL_DTOR - Success
-- Performing Test HAVE_C_WNO_DELETE_NON_VIRTUAL_DTOR
-- 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_CXX_FDIAGNOSTICS_SHOW_OPTION
-- Performing Test HAVE_CXX_FDIAGNOSTICS_SHOW_OPTION - Success
-- Performing Test HAVE_C_FDIAGNOSTICS_SHOW_OPTION
-- Performing Test HAVE_C_FDIAGNOSTICS_SHOW_OPTION - Success
-- Performing Test HAVE_CXX_WNO_LONG_LONG
-- Performing Test HAVE_CXX_WNO_LONG_LONG - Success
-- Performing Test HAVE_C_WNO_LONG_LONG
-- Performing Test HAVE_C_WNO_LONG_LONG - Success
-- Performing Test HAVE_CXX_PTHREAD
-- Performing Test HAVE_CXX_PTHREAD - Success
-- Performing Test HAVE_C_PTHREAD
-- Performing Test HAVE_C_PTHREAD - Success
-- Performing Test HAVE_CXX_FOMIT_FRAME_POINTER
-- Performing Test HAVE_CXX_FOMIT_FRAME_POINTER - Success
-- Performing Test HAVE_C_FOMIT_FRAME_POINTER
-- Performing Test HAVE_C_FOMIT_FRAME_POINTER - Success
-- Performing Test HAVE_CXX_MSSE
-- Performing Test HAVE_CXX_MSSE - Success
-- Performing Test HAVE_C_MSSE
-- Performing Test HAVE_C_MSSE - Success
-- Performing Test HAVE_CXX_MSSE2
-- Performing Test HAVE_CXX_MSSE2 - Success
-- Performing Test HAVE_C_MSSE2
-- Performing Test HAVE_C_MSSE2 - Success
-- Performing Test HAVE_CXX_MNO_AVX
-- Performing Test HAVE_CXX_MNO_AVX - Success
-- Performing Test HAVE_C_MNO_AVX
-- Performing Test HAVE_C_MNO_AVX - Success
-- Performing Test HAVE_CXX_MSSE3
-- Performing Test HAVE_CXX_MSSE3 - Success
-- Performing Test HAVE_C_MSSE3
-- Performing Test HAVE_C_MSSE3 - Success
-- Performing Test HAVE_CXX_MNO_SSSE3
-- Performing Test HAVE_CXX_MNO_SSSE3 - Success
-- Performing Test HAVE_C_MNO_SSSE3
-- Performing Test HAVE_C_MNO_SSSE3 - Success
-- Performing Test HAVE_CXX_MNO_SSE4_1
-- Performing Test HAVE_CXX_MNO_SSE4_1 - Success
-- Performing Test HAVE_C_MNO_SSE4_1
-- Performing Test HAVE_C_MNO_SSE4_1 - Success
-- Performing Test HAVE_CXX_MNO_SSE4_2
-- Performing Test HAVE_CXX_MNO_SSE4_2 - Success
-- Performing Test HAVE_C_MNO_SSE4_2
-- Performing Test HAVE_C_MNO_SSE4_2 - Success
-- Performing Test HAVE_CXX_FFUNCTION_SECTIONS
-- Performing Test HAVE_CXX_FFUNCTION_SECTIONS - Success
-- Performing Test HAVE_C_FFUNCTION_SECTIONS
-- Performing Test HAVE_C_FFUNCTION_SECTIONS - Success
-- Performing Test HAVE_CXX_FVISIBILITY_HIDDEN
-- Performing Test HAVE_CXX_FVISIBILITY_HIDDEN - Success
-- Performing Test HAVE_C_FVISIBILITY_HIDDEN
-- Performing Test HAVE_C_FVISIBILITY_HIDDEN - Success
-- Performing Test HAVE_CXX_FVISIBILITY_INLINES_HIDDEN
-- Performing Test HAVE_CXX_FVISIBILITY_INLINES_HIDDEN - Success
-- Performing Test HAVE_C_FVISIBILITY_INLINES_HIDDEN
-- Performing Test HAVE_C_FVISIBILITY_INLINES_HIDDEN - Failed
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian
-- Found ZLIB: /home/geoff/anaconda3/envs/obj_recog/lib/libz.so (found suitable version "1.2.8", minimum required is "1.2.3") 
-- Found TIFF: /home/geoff/anaconda3/envs/obj_recog/lib/libtiff.so (found version "4.0.6") 
-- Found JPEG: /home/geoff/anaconda3/envs/obj_recog/lib/libjpeg.so  
-- Found WebP: /usr/lib/x86_64-linux-gnu/libwebp.so  
-- Found Jasper: /usr/lib/x86_64-linux-gnu/libjasper.so (found version "1.900.1") 
-- Found ZLIB: /home/geoff/anaconda3/envs/obj_recog/lib/libz.so (found version "1.2.8") 
-- Found PNG: /home/geoff/anaconda3/envs/obj_recog/lib/libpng.so (found version "1.6.22") 
-- Looking for /home/geoff/anaconda3/envs/obj_recog/include/libpng/png.h
-- Looking for /home/geoff/anaconda3/envs/obj_recog/include/libpng/png.h - not found
-- Looking for semaphore.h
-- Looking for semaphore.h - found
-- Performing Test HAVE_CXX_WNO_SHADOW
-- Performing Test HAVE_CXX_WNO_SHADOW - Success
-- Performing Test HAVE_CXX_WNO_UNUSED
-- Performing Test HAVE_CXX_WNO_UNUSED - Success
-- Performing Test HAVE_CXX_WNO_SIGN_COMPARE
-- Performing Test HAVE_CXX_WNO_SIGN_COMPARE - Success
-- Performing Test HAVE_CXX_WNO_UNDEF
-- Performing Test HAVE_CXX_WNO_UNDEF - Success
-- Performing Test HAVE_CXX_WNO_MISSING_DECLARATIONS
-- Performing Test HAVE_CXX_WNO_MISSING_DECLARATIONS - Success
-- Performing Test HAVE_CXX_WNO_UNINITIALIZED
-- Performing Test HAVE_CXX_WNO_UNINITIALIZED - Success
-- Performing Test HAVE_CXX_WNO_SWITCH
-- Performing Test HAVE_CXX_WNO_SWITCH - Success
-- Performing Test HAVE_CXX_WNO_PARENTHESES
-- Performing Test HAVE_CXX_WNO_PARENTHESES - Success
-- Performing Test HAVE_CXX_WNO_ARRAY_BOUNDS
-- Performing Test HAVE_CXX_WNO_ARRAY_BOUNDS - Success
-- Performing Test HAVE_CXX_WNO_EXTRA
-- Performing Test HAVE_CXX_WNO_EXTRA - Success
-- Performing Test HAVE_CXX_WNO_DEPRECATED_DECLARATIONS
-- Performing Test HAVE_CXX_WNO_DEPRECATED_DECLARATIONS - Success
-- 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'
--   Found libdc1394-2, version 2.2.4
-- Checking for module 'libv4l1'
--   Found libv4l1, version 1.10.0
-- Checking for module 'libv4l2'
--   Found libv4l2, version 1.10.0
-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - not found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - found
-- Looking for sys/videoio.h
-- Looking for sys/videoio.h - not found
-- Checking for module 'libavcodec'
--   Found libavcodec, version 57.64.101
-- Checking for module 'libavformat'
--   Found libavformat, version 57.56.100
-- Checking for module 'libavutil'
--   Found libavutil, version 55.34.100
-- Checking for module 'libswscale'
--   Found libswscale, version 4.2.100
-- Checking for module 'libavresample'
--   No package 'libavresample' found
-- Looking for libavformat/avformat.h
-- Looking for libavformat/avformat.h - found
-- Looking for ffmpeg/avformat.h
-- Looking for ffmpeg/avformat.h - not found
-- Checking for module 'libgphoto2'
--   No package 'libgphoto2' found
-- Checking for module 'tbb'
--   Found tbb, version 4.4~20151115
-- ICV: Removing previous unpacked package: /home/geoff/opencv-3.1.0/3rdparty/ippicv/unpack
-- ICV: Unpacking ippicv_linux_20151201.tgz to /home/geoff/opencv-3.1.0/3rdparty/ippicv/unpack...
-- ICV: Package successfully downloaded
-- found IPP (ICV version): 9.0.1 [9.0.1]
-- at: /home/geoff/opencv-3.1.0/3rdparty/ippicv/unpack/ippicv_lnx
-- CUDA detected: 8.0
-- CUDA NVCC target flags: -gencode;arch=compute_20,code=sm_20;-gencode;arch=compute_20,code=sm_21;-gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_30,code=compute_30
-- Could NOT find Doxygen (missing:  DOXYGEN_EXECUTABLE) 
-- To enable PlantUML support, set PLANTUML_JAR environment variable or pass -DPLANTUML_JAR=<filepath> option to cmake
-- Found PythonInterp: /home/geoff/anaconda3/envs/obj_recog/bin/python (found suitable version "2.7.12", minimum required is "2.7") 
我检查并正确安装了
libgtk2-0-dev

在手工构建OpenCV之前,我还编译并重新安装了ffmpeg和gstreamer

make
过程中,我遇到以下错误:

//usr/lib/x86_64-linux-gnu/libsoxr.so.0: undefined reference to `GOMP_parallel@GOMP_4.0'
collect2: error: ld returned 1 exit status
samples/opengl/CMakeFiles/example_opengl_opengl_interop.dir/build.make:107: recipe for target 'bin/opengl-example-opengl_interop' failed
make[2]: *** [bin/opengl-example-opengl_interop] Error 1
CMakeFiles/Makefile2:31556: recipe for target 'samples/opengl/CMakeFiles/example_opengl_opengl_interop.dir/all' failed
make[1]: *** [samples/opengl/CMakeFiles/example_opengl_opengl_interop.dir/all] Error 2
任何帮助都将不胜感激

如果您遵循此链接,可以尝试运行此代码

git clone https://github.com/shantnu/Webcam-Face-Detect.git
cd  cd Webcam-Face-Detect/
sudo python webcam_cv3.py haarcascade_frontalface_default.xml
键入sudo-python对我来说是个好办法,当我只使用python时会出错。所以试着用sudo运行。

如果您遵循此链接,可以尝试运行此代码

git clone https://github.com/shantnu/Webcam-Face-Detect.git
cd  cd Webcam-Face-Detect/
sudo python webcam_cv3.py haarcascade_frontalface_default.xml

键入sudo python对我来说是个好办法,当我只使用python时会出现错误。因此请尝试使用sudo运行。

此错误与libgtk2.0-dev和pkg config无关。可能两者都已安装,但每次尝试运行make时仍会出现相同的错误

当您尝试从不同的源(例如opencv python、官方python等)安装opencv时,经常会发生这种情况。尝试卸载所有与opencv相关的软件包(特别是如果它们不是官方软件包的话),然后重新开始。我甚至不得不重新安装ubuntu一次


pyimagesearch的说明运行良好

此错误与libgtk2.0-dev和pkg-config无关。可能两者都已安装,但每次尝试运行make时仍会出现相同的错误

当您尝试从不同的源(例如opencv python、官方python等)安装opencv时,经常会发生这种情况。尝试卸载所有与opencv相关的软件包(特别是如果它们不是官方软件包的话),然后重新开始。我甚至不得不重新安装ubuntu一次


pyimagesearch的说明运行良好

但是,它不会使用conda/virtual-env,它只适用于系统python版本。但是,它不会使用conda/virtual-env,它只适用于系统python版本。