anki_vector.photos

Photo related classes, functions, events and values.

Classes

PhotographComponent(robot)

Access the photos on Vector.

class anki_vector.photos.PhotographComponent(robot)

Access the photos on Vector.

import anki_vector
import io
from PIL import Image

with anki_vector.Robot() as robot:
    for photo_info in robot.photos.photo_info:
        print(f"Opening photo {photo_info.photo_id}")
        photo = robot.photos.get_photo(photo_info.photo_id)
        image = Image.open(io.BytesIO(photo.image))
        image.show()
Parameters

robot (anki_vector.Robot) – A reference to an instance of the Robot class. Used to make rpc calls.

get_photo(photo_id)

Download a full-resolution photo from the robot’s storage.

import anki_vector
import io
from PIL import Image

with anki_vector.Robot() as robot:
    for photo_info in robot.photos.photo_info:
        print(f"Opening photo {photo_info.photo_id}")
        photo = robot.photos.get_photo(photo_info.photo_id)
        image = Image.open(io.BytesIO(photo.image))
        image.show()
Parameters

photo_id (int) – The id of the photo to download. It’s recommended to get this value from the photo_info list first.

Return type

PhotoResponse

Returns

A response containing all of the photo bytes which may be rendered using another library (like PIL)

get_thumbnail(photo_id)

Download a thumbnail of a given photo from the robot’s storage.

You may use this function to pull all of the images off the robot in a smaller format, and then determine which one to download as full resolution.

import anki_vector
from PIL import Image
import io

with anki_vector.Robot() as robot:
    for photo_info in robot.photos.photo_info:
        photo = robot.photos.get_thumbnail(photo_info.photo_id)
        image = Image.open(io.BytesIO(photo.image))
        image.show()
Parameters

photo_id (int) – The id of the thumbnail to download. It’s recommended to get this value from the photo_info list first.

Return type

ThumbnailResponse

Returns

A response containing all of the thumbnail bytes which may be rendered using another library (like PIL)

load_photo_info()

Request the photo information from the robot.

import anki_vector

with anki_vector.Robot() as robot:
    photo_info = robot.photos.load_photo_info()
    print(f"photo_info: {photo_info}")
Return type

PhotosInfoResponse

Returns

UTC timestamp of the photo and additional data.

property photo_info

The information about what photos are stored on Vector.

If the photo info hasn’t been loaded yet, accessing this property will request it from the robot.

import anki_vector

with anki_vector.Robot() as robot:
    for photo_info in robot.photos.photo_info:
        print(f"photo_info.photo_id: {photo_info.photo_id}") # the id to use to grab a photo from the robot
        print(f"photo_info.timestamp_utc: {photo_info.timestamp_utc}") # utc timestamp of when the photo was taken (according to the robot)
Return type

List[PhotoInfo]