Log in

View Full Version : vision with simpleCV problem


Noam787
14-12-2013, 10:34
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:


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()” :


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.currentfram e)), 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
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
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
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):



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
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:
http://x.x.x.x/jpg/image.jpg

brennonbrimhall
18-12-2013, 17:15
As per the SimpleCV wiki here (https://github.com/sightmachine/SimpleCV/wiki/List-of-IP-Camera-Stream-URLs), 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 http://username:pass@xxx.xxx.xxx.xxx/path/to/stream.


http://x.x.x.x/axis-cgi/mjpg/video.cgi
http://x.x.x.x/axis-cgi/mjpg/video.cgi?camera=&resolution=352x240
http://x.x.x.x/axis-cgi/mjpg/video.cgi?camera=&resolution=640x480
http://x.x.x.x/axis-cgi/mjpg/video.cgi?compression=60&camera=1&des_fps=1
http://x.x.x.x/axis-cgi/mjpg/video.cgi?camera=&resolution=640x480
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.