4

Just installed SimpleCV Version 1.3 Superpack (Python 2.7) and trying the Hello Word application from Practical Computer Vision with SimpleCV

from SimpleCV import Camera, Display, Image
import time

# Initialize the camera
cam = Camera()

# Initialize the display
display = Display()

# Snap a picture using the camera
img = cam.getImage()

On the last line it fails with

OpenCV Error: Bad argument (Array should be CvMat or IplImage) in unknown function, file C:\slave\WinInstallerMegaPack\src\opencv\modules\core\src\array.cpp, line 1238

---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
C:\Python27\lib\site-packages\SimpleCV\Shell\Shell.pyc in <module>()
----> 1 img = cam.getImage()

C:\Python27\lib\site-packages\SimpleCV\Camera.pyc in getImage(self)
    584
    585         frame = cv.RetrieveFrame(self.capture)
--> 586         newimg = cv.CreateImage(cv.GetSize(frame), cv.IPL_DEPTH_8U, 3)
    587         cv.Copy(frame, newimg)
    588         return Image(newimg, self)

error: Array should be CvMat or IplImage

I am using the PS3 Eye camera via the CL-Eye Driver on a Windows 7 PC. That is via usb. The camera works fine otherwise. Any ideas how I can fix this?

Superdooperhero
  • 7,584
  • 19
  • 83
  • 138

2 Answers2

1

cv.CreateImage wants an image or an array. I guess your cv.GetSize(frame) is not returning an array (you ought to check exactly why that is).

You might also try

 newimg = cv.CreateImage(frame, cv.IPL_DEPTH_8U, 3)

where frame should be an IplImage according to the documentation.

http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture-retrieve

But check that RetrieveFrame isn't failing for some reason. For example, there are reports of camera access being denied for conflicts with Skype videochat functions. Are you running some software that might conceivably access the camera?

You can try downloading Process Explorer, and check (Find > Handle or DLL) if there's any process with a handle containing the string 'DeviceClasses'.

UPDATE: my bad, this section only applies to PCI cards and PSEye is USB { As a desperate measure you can take a snapshot with System Restore, and install FGeng's Universal Video Support driver for Windows 7. Then check whether OpenCV recognizes it as a camera connector.

http://www.fgeng.com/drivers.htm

If it doesn't, you can wipe it out with System Restore. It is a desperate measure because anything hogging the camera would probably hog the WDM too, and so chances for success are slim, but you never know. }

UPDATE: did a little bit of research. It turns out that the CL-Eye driver for PSEye is not without problems, depending on the application accessing it. The newer drivers have solved some problems ( threads of February 2012, maybe obsolete ). Sometimes, camera licensing may be an issue ( http://nuigroup.com/forums/viewthread/13699/ ).

You might try with the CL-Eye SDK instead of the driver, since the former explicitly lists OpenCV in the platforms, while the latter does not.

If you already have installed the SDK, you may want to check the camera number (#0, #1) just in case there's another imaging peripheral registered in the system.

Another possibility is to run DxDiag utility to diagnose a possible DirectShow snag.

Trouble here is that there's not much information to be had from the system.

You might want to copy "C:\Python27\lib\site-packages\SimpleCV\Camera.py" into a backup file, and modify it to be more informative, e.g. temporarily adding a print frame between lines 585 and 586 (N.B.: the line must be indented exactly as the one above).

LSerni
  • 55,617
  • 10
  • 65
  • 107
  • cv and frame are part of the internals of SimpleCV and not available to my program, as such I don't understand how to use your code example – Superdooperhero Sep 18 '12 at 19:07
  • So they are, but you can modify (temporarily) the code and see whether you can cadge a more helpful message or error report from that. If you got a "camera in use" exception, you would know to look for some process using the camera, and so on. – LSerni Sep 18 '12 at 19:19
  • I don't feel comfortable modifying the SimpleCV code, I'm a noob – Superdooperhero Sep 18 '12 at 19:27
  • Tried Process Explorer. Killed Firefox and Teamviewer Service. Didn't kill explorer and svchost. Didn't help – Superdooperhero Sep 18 '12 at 19:27
  • The FGEng link is for capture cards and does not seem to support PS3 Eye camera. – Superdooperhero Sep 18 '12 at 19:33
1

There is no problem with SimpleCV. Your camera must be having some issues. Try to re-install OpenCV. Install the latest version of OpenCV(OpenCV 2.4.2)

To see if your camera works with OpenCV,

import cv2
c = VideoCapture(0)
val, img = c.read()
print val #this should be True
print img #this should not be all 0s
Froyo
  • 17,947
  • 8
  • 45
  • 73
  • I'm facing the same issue as this question. My camera works with OpenCV. I get a array of numbers (not all 0s). But with SimpleCV, I still get the same error as in the question. Any suggestions? – codemaniac Nov 25 '16 at 09:57