我试图将捕获的640x480 RGB图像与NAO的前置相机保存到我的计算机。我使用Python和PIL来做到这一点。不幸的是,无论Image.save()方法的参数使用什么图像类型或路径,该图像都不会保存在我的计算机上。尽管用PIL创建的图像包含有效的RGB信息。这里是我的代码示例从choregraphe:NAO无法将捕获的图像保存到本地计算机
import Image
def onInput_onStart(self):
cam_input = ALProxy("ALVideoDevice")
nameId = cam_input.subscribeCamera("Test_Cam", 1, 2, 13, 20)
image = cam_input.getImageRemote(nameId) #captures an image
w = image[0] #get the image width
h = image[1] #get the image height
pixel_array = image[6] #contains the image data
result = Image.fromstring("RGB", (w, h), pixel_array)
#the following line doesnt work
result.save("C:\Users\Claudia\Desktop\NAO\Bilder\test.png", "PNG")
cam_input.releaseImage(nameId)
cam_input.unsubscribe(nameId)
pass
非常感谢你的帮助提前! - 一个沮丧的学生
在choregraphe我的代码是正确缩进 - 我只是搞砸时张贴在这里。 –