Slideshow on Vector’s Face

In this Kinvert Vector example we’ll show you how to make a slideshow on Vector’s face using convert_image_to_screen_data and set_screen_with_image_data.

How Do I Do More With Vector’s Face?

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.

As you saw before in our Vector example on Displaying an Image on Vector’s Face, showing a color image is possible.

But this time we’ll be making a slideshow. In this example we’re only using 2 images. However you could add many more if you wanted to.

For this article, we will be using the Anki Vector SDK. This is one of many of Kinvert’s Anki Vector Examples in Python.

If you want to do the same thing, but with Cozmo, check out the Cozmo SDK.

Vector slideshow on face with convert_image_to_screen_data and set_screen_with_image_data

How about we take a look at some of the commands we’ll be using to make Vector display a slideshow on his face?

Commands for the Face Slideshow

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_head_angle()
  • anki_vector.Robot.behavior.set_lift_height()

There is no documentation available online yet as far as I know. Once it is public we will link to it.

Though we don’t have the documentation to link to, you might be interest in this article Anki wrote about us: https://developer.anki.com/blog/features/interview/from-stem-to-learn/

Python Coding With Vector – Slideshow

Let’s dig in to the code.

First, we use PIL to manipulate images. The image is opened and then change it to screen data with anki_vector.screen.convert_image_to_screen_data(). After we’ve done that we move the lift and head to the position we want.

Finally we show the image with the anki_vector.Robot.screen.set_screen_with_image_data() command.

All of this is done in two for loops. One is just making it so we can show the slideshow more than once.

The other is taking our list of images and cycling through each.

Display Kinvert's logo on Vector's screen using convert_image_to_screen_data andset_screen_with_image_data

Displaying an image on Vector's face using convert_image_to_screen_data and set_screen_with_image_data

Make sure to save the images 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:
    images = ('vector-screen-kinvert-logo.jpg', 'vector-screen-kinvert-k-logo.jpg')
    for _ in range(3):
        for fName in images:
            image = Image.open(fName)
        
            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, 3.0)
            time.sleep(3.0)

How would we add more images to the slideshow?

What if you wanted to make the slideshow faster or slower? How would you modify the code for that?

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

Hope this Anki Vector Example Using the SDK  was helpful. We used the Anki Vector screen and the convert_image_to_screen_data command to make a slideshow. More Vector examples are on the way.

We’d love to hear if this was helpful or if you made any modifications to the code. Please join the conversation in the comments below.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *