NAO无法将捕获的图像保存到本地计算机

时间:2017-05-31 09:56:46

标签: python image-processing python-imaging-library nao-robot choregraphe

我正在尝试用NAO的前置摄像头将捕获的640x480 RGB图像保存到我的电脑上。我正在使用python和PIL这样做。不幸的是,无论我使用什么图像类型或路径用于Image.save() - Method的参数,图像都不会保存在我的计算机上。使用PIL创建的图像包含有效的RGB信息。这是来自choregraphe的代码示例:

REGEX="^interface (.*)"
REGEX_TRUNKRANGEVLAN="switchport trunk allowed vlan (.*)"
REGEX_RANGE="([0-9]+)-([0-9]+)"
REGEX_PO="channel-group.*"

if [[ $line =~ $REGEX_TRUNKRANGEVLAN ]]; then
  #for each pattern match on this line, I need to check
  ranges=$(echo ${BASH_REMATCH[1]} | tr "," "\n")

  for range in $ranges
  do
    if [[ $range =~ $REGEX_RANGE ]]; then
      if [ ${BASH_REMATCH[1]} -le $vlan ] && [ ${BASH_REMATCH[2]} -ge $vlan ]; then
        vlancontained=true
        mode="TRUNK RANGE"
      fi
    else
      if [ $range != "none" ] && [ $range -eq $vlan ]; then
        vlancontained=true
        mode="TRUNK"
      fi
    fi
  done

非常感谢您的帮助! - 一个沮丧的学生

2 个答案:

答案 0 :(得分:1)

在评论中,你说代码是从choregraphe粘贴的,所以我猜你是用choregraphe启动的。 如果是这样,那么代码将被注入您的机器人然后开始。

因此您的图像会保存到NAO硬盘中,我猜您的机器人没有名为“C:\ Users \ Claudia \ Desktop \ NAO \ Bilder \ test.png”的文件夹。

因此,将路径更改为“/home/nao/test.png”,启动代码,然后使用putty登录到您的NAO或使用winscp浏览文件夹(因为它看起来像您正在使用Windows)。

你应该看到你的图像文件。

答案 1 :(得分:0)

为了使代码正确运行,需要正确缩进。您的代码应如下所示:

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

    ...

确保缩进def onInput_onStart(self):方法中的所有内容。

相关问题