This tutorial will show you explain how to display an image from the Nao camera on your local computer.Follow , which you have already done inGetting started with the Nao robot. You should now Before going through this tutorial, you should have the following set up:
Redis is running on your laptop and you
You have SIC installed locally
SIC is running on the Nao
in a virtual environment
Approach
First, let’s create a new file called demo_nao_camera.py
.
...
Code Block | ||
---|---|---|
| ||
import queue import cv2 from sic_framework.core.message_python2 import CompressedImageMessage from sic_framework.devices import Nao from sic_framework.devices.common_naoqi.naoqi_camera import NaoqiCameraConf |
Then, we make a queue and callback function to put the received images in this queue object.
Code Block | ||
---|---|---|
| ||
imgs = queue.Queue() def on_image(image_message: CompressedImageMessage): # we could use cv2.imshow here, but that does not work on Mac OSX imgs.put(image_message.image) |
...
Code Block | ||
---|---|---|
| ||
nao = Nao(ip="192.168.0.210"0", top_camera_conf=conf) nao.top_camera.register_callback(on_image) |
...
Code Block | ||
---|---|---|
| ||
while True: img = imgs.get() cv2.imshow(''"", img[..., ::-1]) # cv2 is BGR instead of RGB cv2.waitKey(1) |
That’s it! If you now run demo_nao_camera.py
, you will receive images from the Nao, put them in a queue, and continuously show the images from this queue. The full code can be found here: https: //github.com/Social-AI-VU/sic_applications/blob/main/demos/demo_nao_camera.py.
Here is the schematic overview of how this program. The camera sends a “stream” of output messages that are received by your computer program.
...