2017-10-31 71 views
2

OpenCV on Python 2.7에는 웹캠에 액세스하는 데 문제가 없습니다. VideoCapture :: read는 항상 아무 것도 반환하지 않습니다 ...웹캠에 액세스 할 수 없습니다. OpenCV 3.3 Python 3

나는 소스에서 컴파일을 시도해 보았습니다.

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 .. 

가 아무것도 내 문제를 일으키는 원인을 나타낼 수 있습니다 구현 타협 변경되었습니다

이 내 cmake이다 (나는 아무 잘못했다고 생각하지 않습니다)?

편집 : 요청으로

:

% 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/

제거 모든 설치하기 전에 주사위와 시도를 실패했습니다.

위의 가이드에서 실행하는 명령이 대상으로하는 Python 버전을 사용하는지 확인하십시오. python을 python36으로 alias하거나 명령에서 바꿉니다.