Ask Your Question

danyup84's profile - activity

2013-09-13 16:06:56 -0600 asked a question Python bindings on Mac Os X Mountain Lion

I'm trying to use Python bindings for capturing a video from my webcam using OpenCv.

I can't get to work this simple test script:

import cv2

video = cv2.VideoCapture(0)

if not video.isOpened():
    print "Can't open video"
    exit(-1)

cv2.namedWindow("Test")

while True:

    result, image = video.read()

    if result:
        print "Frame read!"
        cv2.imshow("Test", image)

video.isOpened() returns True (but the camera led doesn't turn on...), the named window gets opened, but no image is displayed. It seems that the result variable is always False.

I tried to use VideoCapture in a c++ example and it works fine.

This is my cmake output:

-- General configuration for OpenCV 2.4.6.1 =====================================
--   Version control:               unknown
-- 
--   Platform:
--     Host:                        Darwin 12.5.0 i386
--     CMake:                       2.8.11.2
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               Release
-- 
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ Compiler:                /usr/bin/c++  (ver 4.2.0)
--     C++ flags (Release):         -fsigned-char -W -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -W -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -g  -O0 -DDEBUG -D_DEBUG -ggdb3
--     C Compiler:                  /usr/bin/cc
--     C flags (Release):           -fsigned-char -W -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -W -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -g  -O0 -DDEBUG -D_DEBUG -ggdb3
--     Linker flags (Release):      
--     Linker flags (Debug):        
--     Precompiled headers:         NO
-- 
--   OpenCV modules:
--     To be built:                 core imgproc flann highgui features2d calib3d ml video objdetect contrib photo legacy gpu ocl nonfree java python stitching superres ts videostab
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 androidcamera
-- 
--   GUI: 
--     QT:                          NO
--     Cocoa:                       YES
--     OpenGL support:              NO
-- 
--   Media I/O: 
--     ZLib:                        build (ver 1.2.7)
--     JPEG:                        build (ver 62)
--     PNG:                         build (ver 1.5.12)
--     TIFF:                        build (ver 42 - 4.0.2)
--     JPEG 2000:                   build (ver 1.900.1)
--     OpenEXR:                     build (ver 1.7.1)
-- 
--   Video I/O:
--     DC1394 1.x:                  NO
--     DC1394 2.x:                  NO
--     FFMPEG:                      YES
--       codec:                     YES (ver Unknown)
--       format:                    YES (ver Unknown)
--       util:                      YES (ver Unknown)
--       swscale:                   YES (ver Unknown)
--       gentoo-style:              YES
--     OpenNI:                      NO
--     OpenNI PrimeSensor Modules:  NO
--     PvAPI:                       NO
--     GigEVisionSDK:               NO
--     QuickTime:                   NO
--     QTKit:                       YES
--     V4L/V4L2:                    NO/NO
-- 
--   Other third-party libraries:
--     Use IPP:                     NO
--     Use Eigen:                   NO
--     Use TBB:                     NO
--     Use OpenMP:                  NO
--     Use GCD                      YES
--     Use Concurrency              NO
--     Use C=:                      NO
--     Use Cuda:                    NO
--     Use OpenCL:                  YES
-- 
--   OpenCL
--     libraries:                   -framework OpenCL
--     Use AMD FFT:                 NO
--     Use AMD BLAS:                NO
-- 
--   Python:
--     Interpreter:                 /Library/Frameworks/Python.framework/Versions/2.7/bin/python2 (ver 2.7.4)
--     Libraries:                   /Library/Frameworks ...
(more)