Ask Your Question

Cannot grab from camera

asked 2014-03-19 00:58:07 -0500

sean9182 gravatar image

OS X 10.9.2

I can run simplecv and see the examples list. Anything that doesn't require camera input works fine. Otherwise, I get the error:

2014-03-19 01:53:58.018 python[91844:1c07] Surface ID 0x0 2014-03-19 01:53:58.018 python[91844:1c07] Unable to lookup surface 2014-03-19 01:53:58.023 python[91844:8107] * QTCaptureSession warning: Session received the following error while decompressing video: Error Domain=NSOSStatusErrorDomain Code=-50 "The operation couldn’t be completed. (OSStatus error -50.)" (paramErr: error in user parameter list). Make sure that the formats of all video outputs are properly configured. 2014-03-19 01:53:59.009 python[91844:1c07] Can't find surface

And finally...

Cleaned up camera. ERROR: Traceback (most recent call last): File "/Users/sean/.virtualenvs/simplecv/lib/python2.7/site-packages/SimpleCV/examples/detection/", line 12, in <module> cam = Camera() #initialize the camera File "/Users/sean/.virtualenvs/simplecv/lib/python2.7/site-packages/SimpleCV/", line 449, in init self.capture = cv.CaptureFromCAM(camera_index) #This fixes bug with opencv not being able to grab frames from webcams on linux

How do I fix this?</module>

edit retag flag offensive close merge delete


I figured out that I can get the camera working by calling cam = Camera(1). So, how do I set the default camera to 1, so that all the examples work?

sean9182 gravatar imagesean9182 ( 2014-03-19 01:05:41 -0500 )edit

2 Answers

Sort by » oldest newest most voted

answered 2014-03-19 03:43:31 -0500

Bram gravatar image

Does it also work if you try: cam = Camera(-1) ?

If not it might be that the systems shows more than one camera device to SimpleCV, and that the 'last' camera is not the actual camera you want to use. I'm not familiar with osx, but I think it should be possible to turn off the other camera devices.

edit flag offensive delete link more


Camera(1) works. I haven't tried Camera(-1). But even if Camera(-1) works, would I have to change all the examples? Is there a way I can set the default camera used?

sean9182 gravatar imagesean9182 ( 2014-03-19 14:54:16 -0500 )edit

If you can't turn of the other camera devices in osx, than I think indeed that you have to change the examples.

Bram gravatar imageBram ( 2014-03-20 02:11:01 -0500 )edit

answered 2014-03-19 04:13:38 -0500

#include "opencv2/highgui/highgui.hpp" #include <iostream>using namespace cv; using namespace std;

int main(int argc, char* argv[]) { VideoCapture cap(0); // open the video camera no. 0

if(!cap.isOpened())  // if not success, exit program
    cout &lt;&lt; "Cannot open the video file" &lt;&lt; endl;
    return -1;

double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
double dHeight = cap.get([elisa <a href="http://kit](">kit](</a> "elisa kit")); //get the height of frames of the video

cout &lt;&lt; "Frame size : " &lt;&lt; dWidth &lt;&lt; " x " &lt;&lt; dHeight &lt;&lt; endl;

namedWindow("MyVideo",CV_jm3nq7WINDOW_AUTOSIZE); //create a window called "MyVideo"

    Mat frame;

    bool bSuccess =; // read a new frame from video

    if (!bSuccess) //if not success, break loop
        cout &lt;&lt; "Cannot read a frame from video file" &lt;&lt; endl;

    imshow("MyVideo", frame); //show the frame in "MyVideo" window

    if(waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
        cout &lt;&lt; "esc key is pressed by user" &lt;&lt; endl;
        break; </iostream>
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2014-03-19 00:58:07 -0500

Seen: 930 times

Last updated: Mar 19 '14