Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   vision with simpleCV problem (http://www.chiefdelphi.com/forums/showthread.php?t=123153)

Noam787 14-12-2013 10:34

vision with simpleCV problem
 
So this year we are trying onboard vision using raspberryPI. For the image processing we are trying to use simpleCV lib but we got stuck when we tried to connect to the camera’s (Axis M1011) mjpeg stream with the code below:

Code:

import SimpleCV

cam = SimpleCV.JpegStreamCamera('http://10.45.90.11/axis-cgi/mjpg/video.cgi?resolution=320x240')
pic = cam.getImage()

This code is rising an error in the line “pic = cam.getImage()” :

Code:

File "<pyshell#5>", line 1, in <module>
    pic =cam.getImage()
  File "C:\Python27\lib\site-packages\SimpleCV\Camera.py", line 904, in getImage
    return Image(pil.open(StringIO(self.camthread.currentframe)), self)
  File "C:\Python27\lib\site-packages\PIL\Image.py", line 1980, in open
    raise IOError("cannot identify image file")
IOError: cannot identify image file

If anyone can help us it will help us a lot,
GreenBlitz 4590

virtuald 14-12-2013 14:22

Re: vision with simpleCV problem
 
From what I've seen of SimpleCV, it's not really that much simpler than the normal OpenCV python bindings.

Anyways, try the following URL instead: http://x.x.x.x/mjpg/video.mjpg

Noam787 14-12-2013 14:47

Re: vision with simpleCV problem
 
Quote:

Originally Posted by virtuald (Post 1312487)
From what I've seen of SimpleCV, it's not really that much simpler than the normal OpenCV python bindings.

Anyways, try the following URL instead: http://x.x.x.x/mjpg/video.mjpg

we tried this url too. I think the error occurs because of the stream format that the Axis camera is sending is Mjpeg and the camera object reads Jpeg stream. but, i'm not sure those are two different formats.

virtuald 15-12-2013 01:20

Re: vision with simpleCV problem
 
It's very strange to me that it's using PIL to open the images received from the camera... perhaps there's a different class you can use to receive images?

If you're using the OpenCV api, getting images from the camera is straightfoward. You can get images using that URL and the following code (note that error checking is not complete):

Code:


import cv2
import sys

vc = cv2.VideoCapture()
if not vc.open('http://%s/mjpg/video.mjpg' % sys.argv[1]):
    exit(1)

while True:
    retval, img = vc.read()

    if not retval:
        break

    # do something with img...

Perhaps you could capture the images that way, and then create a SimpleCV image object from the numpy array found in img?

otherguy 18-12-2013 15:22

Re: vision with simpleCV problem
 
Quote:

Originally Posted by Noam787 (Post 1312499)
we tried this url too. I think the error occurs because of the stream format that the Axis camera is sending is Mjpeg and the camera object reads Jpeg stream. but, i'm not sure those are two different formats.

We used openCV running on a beaglebone last year with the Axis M1011. Didn't end up on the robot, but one of our students got everything working pretty well.

I'm not sure if it will help with your case as I'm not familiar with simpleCV, but we also had trouble with the mjpeg stream and ended up using the jpeg url for the camera:
Code:

http://x.x.x.x/jpg/image.jpg

brennonbrimhall 18-12-2013 17:15

Re: vision with simpleCV problem
 
As per the SimpleCV wiki here, it looks like these are the list of known IP addresses and paths to the video stream. Make sure you are sending your camera's username and password via the form
Code:

http://username:pass@xxx.xxx.xxx.xxx/path/to/stream
.
  • Code:

    http://x.x.x.x/axis-cgi/mjpg/video.cgi
  • Code:

    http://x.x.x.x/axis-cgi/mjpg/video.cgi?camera=&resolution=352x240
  • Code:

    http://x.x.x.x/axis-cgi/mjpg/video.cgi?camera=&resolution=640x480
  • Code:

    http://x.x.x.x/axis-cgi/mjpg/video.cgi?compression=60&camera=1&des_fps=1
  • Code:

    http://x.x.x.x/axis-cgi/mjpg/video.cgi?camera=&resolution=640x480
  • Code:

    http://x.x.x.x/axis-cgi/mjpg/video.cgi?camera=1&resolution=352x288

Alternatively, you could find the URL that gives you the last picture taken and use that to make an image for processing, like the previous post suggests.

Also, you may want to contact Katherine Scott (from SimpleCV, @kscottz) directly; she's involved with an FRC team and did some debugging with the Axis Camera before.


All times are GMT -5. The time now is 03:03.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi