2017-10-31 11 views
2

OpenCV on Python 2.7は私のウェブカメラにアクセスする上で問題ありません。何らかの理由でPython 3ではできません。VideoCapture :: readは常にnoneを返します。ウェブカメラにアクセスできないOpenCV 3.3 Python 3

私はソースからコンパイルを試みました。

これは私のcmakeの(私は何も悪いことをしたとは思わない)である:

cmake -D CMAKE_BUILD_TYPE=RELEASE \ 
    -D CMAKE_INSTALL_PREFIX=/usr/local \ 
    -D INSTALL_PYTHON_EXAMPLES=ON \ 
    -D INSTALL_C_EXAMPLES=OFF \ 
    -D WITH_V4L=ON \ 
    -D WITH_QT=ON \ 
    -D WITH_OPENGL=ON \ 
    -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \ 
    -D PYTHON_EXECUTABLE3=/usr/bin/python3.6 
    -D PYTHON_EXECUTABLE2=/usr/bin/python2.7 
    -D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/lib64/python3.6/site-packages/numpy/core/include \ 
    -D BUILD_EXAMPLES=ON .. 

は何が私の問題を引き起こしていただきまし示している可能性があり実装betwen変わりましたか?

編集:要求され

% python3.6 -c 'import cv2; print(cv2.getBuildInformation())' 

General configuration for OpenCV 3.3.0 

===================================== 
    Version control:    3.3.0 

    Extra modules: 
    Location (extra):   /io/opencv_contrib/modules 
    Version control (extra):  3.3.0 

    Platform: 
    Timestamp:     2017-09-03T11:00:53Z 
    Host:      Linux 4.4.0-83-generic x86_64 
    CMake:      3.9.0 
    CMake generator:    Unix Makefiles 
    CMake build tool:   /usr/bin/gmake 
    Configuration:    Release 

    CPU/HW features: 
    Baseline:     SSE SSE2 SSE3 
     requested:     SSE3 
    Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 
     requested:     SSE4_1 SSE4_2 AVX FP16 AVX2 
     SSE4_1 (2 files):   + SSSE3 SSE4_1 
     SSE4_2 (1 files):   + SSSE3 SSE4_1 POPCNT SSE4_2 
     FP16 (1 files):   + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX 
     AVX (5 files):    + SSSE3 SSE4_1 POPCNT SSE4_2 AVX 
     AVX2 (7 files):   + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 

    C/C++: 
    Built as dynamic libs?:  NO 
    C++ Compiler:    /opt/rh/devtoolset-2/root/usr/bin/c++ (ver 4.8.2) 
    C++ flags (Release):   -fPIC -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG 
    C++ flags (Debug):   -fPIC -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG 
    C Compiler:     /opt/rh/devtoolset-2/root/usr/bin/cc 
    C flags (Release):   -fPIC -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG 
    C flags (Debug):    -fPIC -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -msse -msse2 -msse3 -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG 
    Linker flags (Release): 
    Linker flags (Debug): 
    ccache:      NO 
    Precompiled headers:   YES 
    Extra dependencies:   /opt/Qt4.8.7/lib/libQtGui.so /opt/Qt4.8.7/lib/libQtTest.so /opt/Qt4.8.7/lib/libQtCore.so /lib64/libz.so stdc++ dl m pthread rt 
    3rdparty dependencies:  ittnotify libprotobuf libjpeg libwebp libpng libtiff libjasper IlmImf 

    OpenCV modules: 
    To be built:     core flann imgproc ml objdetect phase_unwrapping photo plot reg surface_matching video xphoto bgsegm dnn face fuzzy img_hash imgcodecs shape videoio xobjdetect highgui superres bioinspired dpm features2d line_descriptor saliency text calib3d ccalib datasets rgbd stereo structured_light tracking videostab xfeatures2d ximgproc aruco optflow stitching python3 
    Disabled:     world contrib_world 
    Disabled by dependency:  - 
    Unavailable:     cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python2 ts viz cnn_3dobj cvv dnn_modern freetype hdf matlab sfm 

    GUI: 
    QT 4.x:      YES (ver 4.8.7 EDITION = OpenSource) 
    QT OpenGL support:   NO 
    OpenGL support:    NO 
    VTK support:     NO 

    Media I/O: 
    ZLib:      /lib64/libz.so (ver 1.2.3) 
    JPEG:      libjpeg (ver 90) 
    WEBP:      build (ver encoder: 0x020e) 
    PNG:       build (ver 1.6.24) 
    TIFF:      build (ver 42 - 4.0.2) 
    JPEG 2000:     build (ver 1.900.1) 
    OpenEXR:      build (ver 1.7.1) 
    GDAL:      NO 
    GDCM:      NO 

    Video I/O: 
    DC1394 1.x:     NO 
    DC1394 2.x:     NO 
    FFMPEG:      NO 
     avcodec:     NO 
     avformat:     NO 
     avutil:     NO 
     swscale:     NO 
     avresample:    NO 
    GStreamer:     NO 
    OpenNI:      NO 
    OpenNI PrimeSensor Modules: NO 
    OpenNI2:      NO 
    PvAPI:      NO 
    GigEVisionSDK:    NO 
    Aravis SDK:     NO 
    UniCap:      NO 
    UniCap ucil:     NO 
    V4L/V4L2:     NO/NO 
    XIMEA:      NO 
    Xine:      NO 
    Intel Media SDK:    NO 
    gPhoto2:      NO 

    Parallel framework:   pthreads 

    Trace:       YES (with Intel ITT) 

    Other third-party libraries: 
    Use Intel IPP:    NO 
    Use Intel IPP IW:   NO 
    Use Intel IPP Async:   NO 
    Use VA:      NO 
    Use Intel VA-API/OpenCL:  NO 
    Use Lapack:     NO 
    Use Eigen:     NO 
    Use Cuda:     NO 
    Use OpenCL:     YES 
    Use OpenVX:     NO 
    Use custom HAL:    NO 

    OpenCL:      <Dynamic loading of OpenCL library> 
    Include path:    /io/opencv/3rdparty/include/opencl/1.2 
    Use AMDFFT:     NO 
    Use AMDBLAS:     NO 

    Python 2: 
    Interpreter:     NO 

    Python 3: 
    Interpreter:     python (ver 3.6.0) 
    Libraries:     
    numpy:      /opt/python/cp36-cp36m/lib/python3.6/site-packages/numpy/core/include (ver 1.11.3) 
    packages path:    /opt/python/cp36-cp36m/lib/python3.6/site-packages 

    Python (for build):   python 

    Java: 
    ant:       NO 
    JNI:       NO 
    Java wrappers:    NO 
    Java tests:     NO 

    Matlab:      Matlab not found or implicitly disabled 

    Tests and samples: 
    Tests:      NO 
    Performance tests:   NO 
    C/C++ Examples:    NO 

    Install path:     /usr/local 

    cvconfig.h is in:    /io/opencv/build 
----------------------------------------------------------------- 
+1

'print(cv2.getBuildInformation()) 'の出力は何ですか? – zindarod

+0

質問を更新しました(私はその情報を取得する方法が不思議でした) – ovg

+0

私はコンパイル時にV4L2とGStreamerがはいだったと確信しています... – ovg

答えて

0

このガイド続か:https://www.scivision.co/anaconda-python-opencv3/

削除すべてインストールする前に、PIPと試みを失敗します。

上記のガイドで実行するコマンドが、ターゲットとするPythonのバージョンを使用していることを確認してください。 pythonをpython36にエイリアスするか、コマンドで置き換えてください。

関連する問題