zaront / vector

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

Can't retrieve camera feed. #5

Closed JohnMackYouTube05 closed 4 years ago

JohnMackYouTube05 commented 4 years ago

I figured out how to code my program to retrieve the camera feed, but I can't figure out how to put said feed into a pictureBox control. Please help!

JohnMackYouTube05 commented 4 years ago

@zaront

RamblingGeekUK commented 4 years ago

Hi John,

Something like this maybe ? The image is still, I assumed you are using WinForms as you mentioned the pictureBox control.

public async Task<bool> Vector()
        {
            try
            {
                Robot robot = new Robot();
                await robot.GrantApiAccessAsync(Settings.Vector_Name, Settings.Vector_IP, Settings.Vector_Serial, Settings.Vector_Username, Settings.Vector_Password);
                await robot.ConnectAsync(Settings.Vector_Name);

                //gain control over the robot by suppressing its personality
                robot.StartSuppressingPersonality();
                await robot.WaitTillPersonalitySuppressedAsync();

                //say something
                await robot.Audio.SayTextAsync("Hi!");

                robot.Camera.OnImageReceived += (sender, e) =>
                {
                    pictureBox1.Image = e.Image;
                };
                robot.Camera.CameraFeedAsync().ThrowFeedException();

                //disconnect
                await robot.DisconnectAsync();
                return true;
VectorWinFormsImage
JohnMackYouTube05 commented 4 years ago

I will try, but I don’t think I need the grantapiaccess part because I have already granted access

On Sat, Dec 28, 2019 at 7:24 AM Wayne Taylor notifications@github.com wrote:

Hi John,

Something like this maybe ?

`public async Task Vector() { try { Robot robot = new Robot(); await robot.GrantApiAccessAsync(Settings.Vector_Name, Settings.Vector_IP, Settings.Vector_Serial, Settings.Vector_Username, Settings.Vector_Password); await robot.ConnectAsync(Settings.Vector_Name);

        //gain control over the robot by suppressing its personality
        robot.StartSuppressingPersonality();
        await robot.WaitTillPersonalitySuppressedAsync();

        //say something
        await robot.Audio.SayTextAsync("Hi!");

        robot.Camera.OnImageReceived += (sender, e) =>
        {
            pictureBox1.Image = e.Image;
        };
        robot.Camera.CameraFeedAsync().ThrowFeedException();

        //disconnect
        await robot.DisconnectAsync();
        return true;`

[image: VectorWinFormsImage] https://user-images.githubusercontent.com/7108949/71544292-6162d180-2975-11ea-8bc3-345eeefc9891.png

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zaront/vector/issues/5?email_source=notifications&email_token=AD35K7NPZ7GF4R2RBJEJRH3Q25HRPA5CNFSM4J7SFURKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHYJ3DQ#issuecomment-569417102, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD35K7ORE5SCG6QW2NQK4UDQ25HRPANCNFSM4J7SFURA .

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

JohnMackYouTube05 commented 4 years ago

image IT WORKS!! Thank you! Now all I have to do is figure out how to grab his microphone feed... but that's something I have to figure out myself.