Asked — Edited

Camera Control From My Plugin

Hello , I want to control the JD camera from my visual studio plugin , I've try the following code but it doesn't work EZ_B.Camera.GetVideoCaptureDevices();

plz I need ur help as soon as possible .


ARC Pro

Upgrade to ARC Pro

With ARC Pro, your robot is not just a machine; it's your creative partner in the journey of technological exploration.

PRO
Synthiam
#1  

All of my plugins are open source, so you can look to see how to do various things.

Look at the source code of this plugin: https://synthiam.com/redirect/legacy?table=plugin&id=50

In order to get the current active camera device, you need to get the current active camera control. The code in that example plugin will scan all controls and get the first instance of a camera control. The "attach" button will attach to the first camera control and use its video frame event.

Make sure you unregister the video frame event when your control disposes or closes.

PRO
USA
#2  

sample code to connect to an EZB Camera, save the picture in the desktop.

don't forget to change ezbAddress variable to your EZB IP address.


namespace EZConsoleApplication1
{
    using System;
    using System.IO;
    using System.Threading;
    using EZ_B;

    internal class Program
    {
        private static string ezbAddress = "192.168.18.85";
        private static EZB ezb;
        private static EventWaitHandle startEvent;
        private static Camera camera;

        private static void Main(string[] args)
        {
            using (ezb = new EZB())
            {
                Console.WriteLine("Connecting to EZ-B");
                ezb.Connect(ezbAddress);

                if (!ezb.IsConnected)
                {
                    Console.WriteLine("Unable to connect to EZ-B");
                    return;
                }

                using (camera = new EZ_B.Camera(ezb))
                {
                    startEvent = new EventWaitHandle(false, EventResetMode.AutoReset);

                    camera.OnNewFrame += CameraOnNewFrame;
                    camera.StartCamera(new ValuePair("EZB://" + ezbAddress), 160, 120);

                    //wait 10 seconds for the first camera frame
                    if (startEvent.WaitOne(10000))
                    {
                        //Save an image on the desktop
                        camera.SaveImageAsJPEG(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "capture1.jpg"));
                        camera.StopCamera();
                    }
                    else
                    {
                        Console.WriteLine("Unable to connect to camera");
                    }
                }

                Console.WriteLine("Done!");
                ezb.Disconnect();
            }
        }

        private static void CameraOnNewFrame()
        {
            startEvent.Set();
        }
    }
}

PRO
Synthiam
#3  

ptp, that is for creating a standalone application. The OP is asking about creating a plugin. A plugin runs in the ARC environment, which will have a project with an existing camera control.

The plugin will search and locate an existing camera control and attach itself to it.

PRO
USA
#4  

you are right, my bad!

#6  

thanks ptp you give my what I need ,that's to control the JD camera from visual studio but i need to control it from my form . would you help me to do that ?

#7  

DJ Sures you didn't get what I mean . I need to control the camera from my plugin . I mean ,I want to display what the robot see from my own windows form ,Did you get it ?

PRO
USA
#8  

you have both examples, standalone application and ARC skill plugin.

There are more advantages if you migrate to an ARC skill plugin: you will have more robust ecosystem, you can mix custom scripting (EZ-Script) you can communicate with other plugins you have more API's, and you have a modular approach, for example breaking a complex problem in multiple plugins.

Also DJ's plugins are open source, so it's easy to improve an existing idea.

Whatever road you choose, it's ok.

If you are using a Form, the standalone code still works, let us know if you need more help.