Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

JpegStreamCamera IOError when running getImage

Hi there! I'm working through the O'Reilly book Practical Computer Vision with SimpleCV (loving it) and got stumped when attempting to access a fake IP camera on my iPhone.

I'm running SimpleCV 1.3.0 on a MacBook and IP Cam iPhone app on an iPhone 4S.

With the camera's mjpeg address at *192.168.1.94/video.mjpg I run:

from SimpleCV import JpegStreamCamera
cam = JpegStreamCamera("*192.168.1.94/video.mjpg")
img = cam.getImage()

and it returns:
---------------------------------------------------------------------------
IOError Traceback (most recent call last)
/Library/Python/2.7/site-packages/SimpleCV-1.3-py2.7.egg/SimpleCV/Shell/Shell.pyc in <module>()
----> 1 img = cam.getImage()

/Library/Python/2.7/site-packages/SimpleCV-1.3-py2.7.egg/SimpleCV/Camera.pyc in getImage(self)
902
903 self.capturetime = self.camthread.threadcapturetime
--> 904 return Image(pil.open(StringIO(self.camthread.currentframe)), self)
905
906

/Library/Python/2.7/site-packages/SimpleCV-1.3-py2.7.egg/SimpleCV/ImageClass.pyc in init(self, source, camera, colorSpace, verbose, sample, cv2image)
814 #*opencv.willowgarage.com/documentation/python/cookbook.html
815 self.
bitmap = cv.CreateImageHeader(self.pil.size, cv.IPLDEPTH8U, 3)
--> 816 cv.SetData(self.
bitmap, self.pil.tostring())
817 self.
colorSpace = ColorSpace.BGR
818 cv.CvtColor(self.bitmap, self.bitmap, cv.CVRGB2BGR)

/Library/Python/2.7/site-packages/PIL/Image.pyc in tostring(self, encoder
name, *args)
530 args = self.mode
531
--> 532 self.load()
533
534 # unpack data

/Library/Python/2.7/site-packages/PIL/ImageFile.pyc in load(self)
213
214 if not self.map and e < 0:
--> 215 raiseioerror(e)
216
217 # post processing

/Library/Python/2.7/site-packages/PIL/ImageFile.pyc in raise
ioerror(error)
50 if not message:
51 message = "decoder error %d" % error
---> 52 raise IOError(message + " when reading image file")
53
54 #

IOError: broken data stream when reading image file

Any idea what I'm doing wrong? It doesn't make sense to me. Any help is much appreciated!
*eliminated "http://" from various urls due to karma restrictions for posting links.

JpegStreamCamera IOError when running getImage

Hi there! I'm working through the O'Reilly book Practical Computer Vision with SimpleCV (loving it) and got stumped when attempting to access a fake IP camera on my iPhone.

I'm running SimpleCV 1.3.0 on a MacBook and IP Cam iPhone app on an iPhone 4S.

With the camera's mjpeg address at *192.168.1.94/video.mjpg I run:

from SimpleCV import JpegStreamCamera
cam = JpegStreamCamera("*192.168.1.94/video.mjpg")
img = cam.getImage()

and it returns:
---------------------------------------------------------------------------
IOError Traceback (most recent call last)
/Library/Python/2.7/site-packages/SimpleCV-1.3-py2.7.egg/SimpleCV/Shell/Shell.pyc in <module>()
----> 1 img = cam.getImage()

/Library/Python/2.7/site-packages/SimpleCV-1.3-py2.7.egg/SimpleCV/Camera.pyc in getImage(self)
902
903 self.capturetime = self.camthread.threadcapturetime
--> 904 return Image(pil.open(StringIO(self.camthread.currentframe)), self)
905
906

/Library/Python/2.7/site-packages/SimpleCV-1.3-py2.7.egg/SimpleCV/ImageClass.pyc in init(self, source, camera, colorSpace, verbose, sample, cv2image)
814 #*opencv.willowgarage.com/documentation/python/cookbook.html
815 self.
bitmap = cv.CreateImageHeader(self.pil.size, cv.IPLDEPTH8U, 3)
--> 816 cv.SetData(self.
bitmap, self.pil.tostring())
817 self.
colorSpace = ColorSpace.BGR
818 cv.CvtColor(self.bitmap, self.bitmap, cv.CVRGB2BGR)

/Library/Python/2.7/site-packages/PIL/Image.pyc in tostring(self, encoder
name, *args)
530 args = self.mode
531
--> 532 self.load()
533
534 # unpack data

/Library/Python/2.7/site-packages/PIL/ImageFile.pyc in load(self)
213
214 if not self.map and e < 0:
--> 215 raiseioerror(e)
216
217 # post processing

/Library/Python/2.7/site-packages/PIL/ImageFile.pyc in raise
ioerror(error)
50 if not message:
51 message = "decoder error %d" % error
---> 52 raise IOError(message + " when reading image file")
53
54 #

IOError: broken data stream when reading image file

Any idea what I'm doing wrong? It doesn't make sense to me. Any help is much appreciated!
*eliminated "http://" from various urls due to karma restrictions for posting links.

!!!EDIT!!!

Thanks for the reply. That's not working, either. I run

from SimpleCV import JpegStreamCamera, Display
import time

disp = Display()
ip = '192.168.1.94'
address = 'http://' + str(ip) + '/video.mjpg'
print address
cam = JpegStreamCamera(address)

while disp.isNotDone():

img = cam.getImage()
time.sleep(1)
img.save(disp)

, and I get:

$ python IPcamera1.py
*192.168.1.94/video.mjpg
/Library/Python/2.7/site-packages/SimpleCV-1.3-py2.7.egg/SimpleCV/Camera.py:899: UserWarning: Timeout fetching JpegStream at *192.168.1.94/video.mjpg
warnings.warn("Timeout fetching JpegStream at " + self.url)
ERROR:
Traceback (most recent call last):
File "IPcamera1.py", line 14, in <module>
img.save(disp)
AttributeError: 'NoneType' object has no attribute 'save'

I go to the browser at that address and I see the image from the camera.