Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

VideoCapture(0) stuck on my mac(OSX 10.9.5 Python 2.7 OpenCV 2.4)!

I am doing video streaming by using VideoCapture(0). There are two scripts:main.py(use for get the frame). camera.py(use for return the frame captured by camera) The system is deployed in Flask.
Here is my camera script:
%camera.py
import cv2

class VideoCamera(object):
def __init__(self):
print 'before video success!'
self.video = cv2.VideoCapture(1) *it stuck at this line!
print 'after video success!'
self.video.set(3,320)
self.video.set(4,240)
self.video.set(15, 0.1)

def __del__(self):
self.video.release()

def get_frame(self):

    success, image = self.video.read()
    ret, jpeg = cv2.imencode('.jpg', image)
    return jpeg.tobytes()

There is no error,just print 'before video success!' and stuck at this line!

click to hide/show revision 2
retagged

updated 2015-03-10 06:27:44 -0600

berak gravatar image

VideoCapture(0) stuck on my mac(OSX 10.9.5 Python 2.7 OpenCV 2.4)!

I am doing video streaming by using VideoCapture(0). There are two scripts:main.py(use for get the frame). camera.py(use for return the frame captured by camera) The system is deployed in Flask.
Here is my camera script:
%camera.py
import cv2

class VideoCamera(object):
def __init__(self):
print 'before video success!'
self.video = cv2.VideoCapture(1) *it stuck at this line!
print 'after video success!'
self.video.set(3,320)
self.video.set(4,240)
self.video.set(15, 0.1)

def __del__(self):
self.video.release()

def get_frame(self):

    success, image = self.video.read()
    ret, jpeg = cv2.imencode('.jpg', image)
    return jpeg.tobytes()

There is no error,just print 'before video success!' and stuck at this line!