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.
For this article, we will be using the Anki Vector SDK. This is one of many of Kinvert’s Anki Vector Examples in Python.
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:
- anki_vector.screen.convert_image_to_screen_data()
- anki_vector.Robot.screen.set_screen_with_image_data()
- anki_vector.Robot.behavior.set_lift_height()
- anki_vector.Robot.behavior.set_head_angle()
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.
In Conclusion
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.
Contact Us For Help and Advice
If you’re interested in taking a Cozmo Camp Click Here or check out our Courses Page. We also use Cozmo in our Robotics Kids Class K-12.
Thank you for the information. I have really enjoyed learning about your website and will be looking to get my nephew(s) involved with some of your courses.
Just FYI – (and i’m new to Vector) I could see the picture just fine but it was behind his eyes. Wonder if it is a bug or they changed something in this version of the sdk. Would love to know if you are experiencing the same
This has happened to me as well. I still don’t know what causes it.
Sometimes if I display the image more than once, in a loop, it will show the eyes once, then the next time through the loop the eyes will stop being shown.
I haven’t had time to dig in and see why. When I find out I’ll be sure to update here.
Thanks Sean!