Ask Your Question

Revision history [back]

Cannot access camera on Mac Lion System!

Hi, I am using python on the Mac Lion system. I built the latest opencv package downloaded from this website with With_V4L = ON. I wrote the simplest code as follows:

import cv2
import cv
import numpy as np
import time

def main():
    capture = cv2.VideoCapture(0)
    print capture.isOpened()
    print capture
    time.sleep(10)
    cv2.namedWindow("Camera")
    capture.set(cv.CV_CAP_PROP_FRAME_WIDTH, 640)
    capture.set(cv.CV_CAP_PROP_FRAME_HEIGHT, 480)

    while (capture.isOpened()):
        ret, image = capture.read() 
        cv2.imshow("Camera",image)
        k = cv2.waitKey(30)
        if k == 27:
            break

if __name__ == "__main__":
    main()

The system keeps popping out this error: File "opencvtest.py", line 31, in <module> main() File "opencvtest.py", line 25, in main cv2.imshow("Camera",image) cv2.error: /Users/conangausslee/Downloads/opencv-2.4.6.1/modules/highgui/src/window.cpp:261: error: (-215) size.width>0 && size.height>0 in function imshow

I have no idea what is going on here. Can Anybody tell me what is the problem?