zaront / vector

C# API for the Anki Vector robot.
MIT License
13 stars 8 forks source link

Put moving images on Vector's screen? #7

Open JohnMackYouTube05 opened 4 years ago

JohnMackYouTube05 commented 4 years ago

Would there be a way to, per say, take a video file, or a GIF, for example, and display all frames of the file on Vector's screen? Take a video file, extract each frame as an image, and then display them on Vector's screen, kind of like how you can take the camera feed from Vector, and put it right back on Vector's screen. Or read a GIF and put it on screen.

If this is possible, please let me know. @zaront

zaront commented 4 years ago

Sure. Just call robot.Screen.SetScreenImage a bunch of times for each frame.

Here is an example I made for you that will do just that.

//download and play a gif on screen
var client = new WebClient();
client.DownloadFile("https://media1.giphy.com/media/5kq0GCjHA8Rwc/giphy.gif", "video.gif");
var video = Image.FromFile("video.gif");
var dimension = new FrameDimension(video.FrameDimensionsList[0]);
for (int loop = 0; loop < 5; loop++)
{
    for (int frame = 0; frame < video.GetFrameCount(dimension); frame++)
    {
        video.SelectActiveFrame(dimension, frame);
        await robot.Screen.SetScreenImage(video);
    }
}

Hope that helps.

JohnMackYouTube05 commented 4 years ago

Thank you! I can work with this to make it do what I want.

On Tue, Mar 24, 2020 at 11:38 PM Zaron Thompson notifications@github.com wrote:

Sure. Just call robot.Screen.SetScreenImage a bunch of times for each frame.

Here is an example I made for you that will do just that.

//download and play a gif on screenvar client = new WebClient();client.DownloadFile("https://media1.giphy.com/media/5kq0GCjHA8Rwc/giphy.gif", "video.gif");var video = Image.FromFile("video.gif");var dimension = new FrameDimension(video.FrameDimensionsList[0]);for (int loop = 0; loop < 5; loop++) { for (int frame = 0; frame < video.GetFrameCount(dimension); frame++) { video.SelectActiveFrame(dimension, frame); await robot.Screen.SetScreenImage(video); } }

Hope that helps.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zaront/vector/issues/7#issuecomment-603636059, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD35K7LZYTKESEI3SFANTXDRJGDFNANCNFSM4LS6PCSQ .

-- Sent from John Mack Skype - yellowboy111 Hangouts - John Mack