opencv getImage() error
Question: I wrapped opencv today with simplecv python interface. After going through the
official [SimpleCV Cookbook](http://simplecv.org/doc/cookbook.html) I was able
to successfully [Load, Save](http://simplecv.org/doc/cookbook.html#loading-
and-saving-images), and
[Manipulate](http://simplecv.org/doc/cookbook.html#image-manipulation) images.
Thus, I know the library is being loaded properly.

However, under the [Using a Camera, Kinect, or Virtual
Camera](http://simplecv.org/doc/cookbook.html#using-a-camera-kinect-or-
virtualcamera) heading I was unsuccessful in running some commands. In
particular, `mycam = Camera()` worked, but `img = mycam.getImage()` produced
the following error:

    
    
    In [35]: img = mycam.getImage().save()
    OpenCV Error: Bad argument (Array should be CvMat or IplImage) in cvGetSize, file /home/jordan/OpenCV-2.2.0/modules/core/src/array.cpp, line 1237
    ---------------------------------------------------------------------------
    error                                     Traceback (most recent call last)
    
    /home/simplecv/<ipython console> in <module>()
    
    /usr/local/lib/python2.7/dist-packages/SimpleCV-1.1-py2.7.egg/SimpleCV/Camera.pyc in getImage(self)
        332 
        333         frame = cv.RetrieveFrame(self.capture)
    --> 334         newimg = cv.CreateImage(cv.GetSize(frame), cv.IPL_DEPTH_8U, 3)
        335         cv.Copy(frame, newimg)
        336         return Image(newimg, self)
    
    error: Array should be CvMat or IplImage
    

I'm running Ubuntu Natty on a HP TX2500 tablet. It has a built in webcam,
(CyberLink Youcam?) Has anybody seen this error before? I've been all over the
web today looking for a solution, but nothing seems to be doing the trick.

**Update 1** : I tested cv.QueryFrame(capture) using the code found here [in a
separate Stack Overflow
question](http://stackoverflow.com/questions/4929721/opencv-python-grab-
frames-from-a-video-file) and it worked; so I've pretty much nailed this down
to a webcam issue.

**Update 2** : In fact, I get the exact same errors on a machine that doesn't
even have a webcam! It's looking like the TX2500 is not compatible...


Answer: since the error raised from Camera.py of SimpleCV, you need to debug the
getImage() method. If you can edit it:

    
    
    def getImage(self):
        if (not self.threaded):
            cv.GrabFrame(self.capture)
    
        frame = cv.RetrieveFrame(self.capture)
        import pdb       # <-- add this line
        pdb.set_trace()  # <-- add this line
        newimg = cv.CreateImage(cv.GetSize(frame), cv.IPL_DEPTH_8U, 3)
        cv.Copy(frame, newimg)
        return Image(newimg, self)
    

then run your program, it will be paused as pdb.set_trace(), here you can
inspect the type of frame, and try to figure out how get the size of frame.

Or you can do the capture in your code, and inspect the frame object:

    
    
    mycam = Camera()
    cv.GrabFrame(mycam.capture)
    frame = cv.RetrieveFrame(mycam.capture)
    

