Kinvert brings you this example of displaying an image on Vector’s screen using the convert_image_to_screen_data and set_screen_with_image_data commands. If you want to know how to display an image on the Vector screen, this is the article for you.
What Can We Do With Vector’s Screen?
If you have read our article about Anki Cozmo vs Vector Comparison you’ll know a big difference. While Cozmo has a screen that only shows blue, Vector has a full color screen.
So what can we do with this new color screen?
Well for one, we can display color images on it. That is what we will be doing in this Vector example.
Also, eventually we should be able to directly draw on his face with lines and text. We are still in Pre-Alpha at the time of writing this. So these features don’t seem to be available yet.
You can do the same thing with the Cozmo SDK as well if you own a Cozmo robot.
Next, we will look at the commands we’ll be using to make this happen.
Anki Vector Screen Image Display Commands
What commands will we be using? Here they are:
We will link to the documentation once it is available online.
There should be online documentation coming soon from Anki. For now, you can look at the article Anki wrote about us here: https://developer.anki.com/blog/features/interview/from-stem-to-learn/
The Code – Display Image on Vector’s Screen
Time to dig in to the code.
First, we need to use PIL to manipulate images. We open the image and then turn it in to screen data with anki_vector.screen.convert_image_to_screen_data(). Once we have that done we move the lift and head to the pose we are looking for.
How that we have all that done we can actually put the image on Vector’s screen. We do that with the anki_vector.Robot.screen.set_screen_with_image_data() command.
Make sure to save the image above in to the same folder as your code. Also remember Kinvert reserves all rights to Kinvert’s logo.
""" Copyright Kinvert All Rights Reserved If you would like to use this code for business or education please contact us for permission at: www.kinvert.com/ """ import anki_vector import time from PIL import Image with anki_vector.Robot() as robot: image = Image.open('vector-screen-kinvert-logo.jpg') screen_data = anki_vector.screen.convert_image_to_screen_data(image) robot.behavior.set_lift_height(50.0) robot.behavior.set_head_angle(anki_vector.util.degrees(28.0)) robot.screen.set_screen_with_image_data(screen_data, 10.0) time.sleep(10.0)
How would we display the image twice as long?
How would we raise the lift higher and have Vector look down while displaying an image?
How would you display a different image on Vector’s face? Keep in mind you need a resolution of 184 X 96 pixels as this is the resolution of Vector’s IPS Display screen.
We hope you enjoyed this Anki Vector Example Using the SDK using the Anki Vector screen and the convert_image_to_screen_data command. We will be making more Vector examples so please stay tuned.
Please let us know in the comments below if this helped you, or if you made any cool modifications. We’d love to hear from you.
Cozmo Examples, Tutorials, and Projects for STEM Education Curriculum is the place for Cozmo examples, in case you don’t have Vector yet. We also have an article on the Anki Cozmo SDK.