Ask Your Question

2 external webcams is a problem?

asked 2012-10-10 16:38:30 -0500

dramaticlook gravatar image

Hi, I'm having more and more process with my stereo application each day. On the next step I want to try it using two external webcams.

    from SimpleCV import *

    cam1 = SimpleCV.Camera(1)
    cam2 = SimpleCV.Camera(2)
    l = cam1.getImage()#left
    r = cam2.getImage()#right
    res = (2*l.width , l.height)
    display = Display( resolution = res )
    display.done = False
        while not display.isDone():
          l = cam1.getImage()#left
          r = cam2.getImage()#right
          #Assuming that the camera is calibrated and images what you get are rectified too.
          stereo = StereoCamera(l,r)
          if pointsInited==0:
            F,pts1,pts2 = stereo.findFundamentalMat(thresh=1000.00, minDist=0.5) 
            print "------\n"
          sideBySideImage = l.sideBySide(r)

I've tested one of my external webcams and it works nice but when I try to use two of them, I get the following error:

Traceback (most recent call last):
  File "C:\Users\pek1\Desktop\ingenuitas-SimpleCV-1.3-58-g256c52e\ingenuitas-SimpleCV-256c52e\SimpleCV\examples\examples\stereo\", line 43, in <module>
    r = cam2.getImage()#right
  File "C:\Python27\lib\site-packages\SimpleCV\", line 586, in getImage
    newimg = cv.CreateImage(cv.GetSize(frame), cv.IPL_DEPTH_8U, 3)
error: Array should be CvMat or IplImage

Can anybody help me please?:)

edit retag flag offensive close merge delete


Im using 1.3 superpack for wındows already:) Also when you release another superpack for Lion OSx can you please provide some more detailed example (with buttons labels etc) with different gui libs, (tkinter, gtk, sgc etc). However Im not sure this is related with version :/

dramaticlook gravatar imagedramaticlook ( 2012-10-11 16:27:06 -0500 )edit

@kscottz the code you posted works. Im using 1.3 superpack for wındows. Ive seen that my code also did work for a few sec. Then it crashed and now when Im testing it, it crashes with the error error: Array should be CvMat or IplImage. Maybe i get error because i use time.sleep.

dramaticlook gravatar imagedramaticlook ( 2012-10-13 08:32:27 -0500 )edit

@kscottz what Im trying to do is . if u wanna take a look:) Thanks

dramaticlook gravatar imagedramaticlook ( 2012-10-14 04:06:17 -0500 )edit

@vijaym123 I did as you said "stereo = StereoImage(l,r)" and I get the error "NameError: name 'StereoImage' is not defined" you are possibly right that there is an installation problem. I downloaded the 1.3 superpack. I will try to reinstall it. Thanks.

dramaticlook gravatar imagedramaticlook ( 2012-10-14 14:58:46 -0500 )edit

1 Answer

Sort by » oldest newest most voted

answered 2012-10-12 09:11:10 -0500

kscottz gravatar image

updated 2012-10-12 09:33:36 -0500

I am not even sure we tested the stereo stuff with multiple cameras as the camera library can be super flakey with multiple cameras (i.e. the camera number is dependent on the order they are connected). I think modifying the camera threaded parameter might fix things. You may want to try building SimpleCV from the development git repository (not the stable master branch). We are getting enough questions on this issue that I will try to block off some time to see if I can't get a work around running.

So I tried doing a stereo rig on Ubuntu 12 with two identical iPevo cameras and I can confirm that stereo does work. Here is the code:

cam1 = Camera(1)
cam2 = Camera(2)
img1 = cam1.getImage().scale(.3)
img2 = cam2.getImage().scale(.3)
img3 = img1.sideBySide(img2)"stereo.png")

The next question is if your issue is a code issue, an OS issue, or a camera issue. Can you please post this information so we can debug. I will repeat this on my Mac to see if it works.

edit flag offensive delete link more


I just double checked on my Mac and stereo cameras work. I tested your code and it appears that you are using an older version of SimpleCV so the code doesn't work. I highly suggest you update to the development branch on github if you want to do any stereo operations.

kscottz gravatar imagekscottz ( 2012-10-12 09:40:46 -0500 )edit

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: 2012-10-10 16:38:30 -0500

Seen: 586 times

Last updated: Oct 12 '12