Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将PyGame网络摄像头流到Glade界面_Python_Gtk_Pygame_Pygtk_Glade - Fatal编程技术网

Python 将PyGame网络摄像头流到Glade界面

Python 将PyGame网络摄像头流到Glade界面,python,gtk,pygame,pygtk,glade,Python,Gtk,Pygame,Pygtk,Glade,我目前正在为望远镜开发GUI。 我有一个摄像头通过USB连接到一个树莓圆周率。 一个小python脚本正在将imageData读取为字符串,并通过套接字将其发送到我的pc。现在我想在GTK图像中显示这个imageString def updateWebCamPic(self, imageString): print "update" img = Image.open(StringIO(imageString)) self.image.set_from_pixbuf(sel

我目前正在为望远镜开发GUI。
我有一个摄像头通过USB连接到一个树莓圆周率。 一个小python脚本正在将imageData读取为字符串,并通过套接字将其发送到我的pc。现在我想在GTK图像中显示这个imageString

def updateWebCamPic(self, imageString):
    print "update"
    img = Image.open(StringIO(imageString))
    self.image.set_from_pixbuf(self.image2pixbuf(img))
    print "updatet"

def getPixBufRGB8Bit(self, im):
    arr = numpy.array(im)
    return GdkPixbuf.Pixbuf.new_from_data((arr, Gdk.COLORSPACE_RGB, 8))

def image2pixbuf(im):
    """Convert Pillow image to GdkPixbuf"""
    data = im.tobytes()
    w, h = im.size
    data = GLib.Bytes.new(data)
    pix = GdkPixbuf.Pixbuf.new_from_bytes(data, GdkPixbuf.Colorspace.RGB,
            False, 8, w, h, w * 3)
    return pix
但我得到了以下错误:

raise IOError("cannot identify image file")
IOError: cannot identify image file
[编辑]:

if str(received[0]).startswith("<|Image|>"):
    image=received[0][9:]
    self.parrent.updateWebCamPic(image)
如果str(已收到[0])。开始使用(“”):
图像=收到[0][9:]
self.parrent.updateWebCamPic(图像)

始终显示完整的错误消息。代码中的哪一行生成此错误?可能是
Image.open()
Image.open()
expect数据格式为PNG、JPG、GIF等。请参阅:
string
可与其他Python模块中的
fromstring()
一起使用Image.open()中的但是如何将pygame图像转换为png?或者如何显示曲面?您可能会使用
PIL
pill
然后选中
PIL.Image.fromstring()
,或者始终放置完整的错误消息。代码中的哪一行生成此错误?可能是
Image.open()
Image.open()
expect数据格式为PNG、JPG、GIF等。请参阅:
string
可与其他Python模块中的
fromstring()
一起使用Image.open()中的但是如何将pygame图像转换为png?或者如何显示曲面?您可能会使用
PIL
Pillow
然后选中
PIL.Image.fromstring()
或者更确切地说