How to get image from robot

  1. create RobocupVision proxy
  2. call vision.getBGR24Image (or other functions for different formats)
  3. convert binary data to numpy.array with numpy.fromstring
  4. convert to other image format (like RGB) with OpenCV

In [8]:
%matplotlib inline

from naoqi import ALProxy
import numpy as np
import matplotlib.pyplot as plot
import cv2

vision = ALProxy('RobocupVision', 'nao1.local', 9559)

In [5]:
cameraId = 0 # 0 for
data = vision.getBGR24Image(cameraId)
image = np.fromstring(data, dtype=np.uint8).reshape((480, 640, 3))

In [10]:
rgb_img = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
plot.imshow(rgb_img)


Out[10]:
<matplotlib.image.AxesImage at 0x7fa7b34349d0>

In [ ]: