GigeVision icon indicating copy to clipboard operation
GigeVision copied to clipboard

Baumer camera integration

Open lsnaidero opened this issue 2 years ago • 11 comments

I'm tring this project using a Baumer Camera model VCXG-25M but the project doesn't find the device.

I'm unable to attach to the event new frame and acquire images. Follow the code I used:

gvcp = new Gvcp() { CameraIp = "10.0.5.12" }; Dictionary<string, string> registers = await gvcp.ReadAllRegisterAddressFromCameraAsync().ConfigureAwait(false); List<CameraInformation> devices = await gvcp.GetAllGigeDevicesInNetworkAsnyc();

        this.camera = new Camera(gvcp);
        camera.FrameReady += FrameReady;

What is wrong? Do you never tried the project with Baumer camera? Tanks

lsnaidero avatar Aug 22 '22 11:08 lsnaidero

I have tested one Baumer camera.

Touseefelahi avatar Aug 22 '22 12:08 Touseefelahi

You need to allow the program to access the private and public network You can do it by adding an exception for this program to have access to private network in firewall settings

Touseefelahi avatar Aug 22 '22 12:08 Touseefelahi

@lsnaidero and did you call this start stream method? (Mentioned in the readme)

//For multiple interfaces you can define the Rx IP as: (In this example 192.168.10.221 is the PC IP)
bool isStarted = await camera.StartStreamAsync("192.168.10.221").ConfigureAwait(false);

Touseefelahi avatar Aug 22 '22 12:08 Touseefelahi

Yes I did

I wrote you only a little part of my code

I insert in this mail breafly the code I used, as you see I made a lot of tries before write you

Thanks in advance for your support

    public Form1()
    {
        InitializeComponent();
       // SpecificCT_Parameters.Instance.Create();
    }

    Gvcp gvcp=null;
    Camera camera=null;

    private async void btnCreate_Click(object sender, EventArgs e)
    {

        gvcp = new Gvcp() { CameraIp = "10.0.5.12" };
        Dictionary<string, string> registers = await gvcp.ReadAllRegisterAddressFromCameraAsync().ConfigureAwait(false);
        List<CameraInformation> devices = await gvcp.GetAllGigeDevicesInNetworkAsnyc();

        this.camera = new Camera(gvcp);
        camera.FrameReady += FrameReady;




        //Console.WriteLine("btnCreate_Click");
        //gvcp = new Gvcp() { CameraIp = "10.0.5.12" };
        //Dictionary<string, string> registers = await gvcp.ReadAllRegisterAddressFromCameraAsync().ConfigureAwait(false);

        //GvcpReply value = await gvcp.ReadRegisterAsync(ipCamera, Enums.GvcpRegister.CCP);
        //camera = new Camera();

        ////camera = new Camera
        ////{
        ////    IsRawFrame = false,
        ////    IsMulticast = true,
        ////    MulticastIP = "10.0.1.177"
        ////};
        //var listOfDevices = await camera.Gvcp.GetAllGigeDevicesInNetworkAsnyc();//.ConfigureAwait(false);
        //if (listOfDevices.Count > 0)
        //{
        //    camera.IP = listOfDevices.FirstOrDefault()?.IP;
        //}
        //camera.FrameReady += FrameReady;



        //this.gvcp = new Gvcp();
        //gvcp.CameraIp = "10.0.5.12";

        //this.camera = new Camera(gvcp);
        //camera.FrameReady += FrameReady;


    }

    private void FrameReady(object sender, byte[] e)
    {
        // e contains the raw data in bytes
        int width = (int)camera.Width;
        int height = (int)camera.Height;
        bool IsColored = !camera.IsRawFrame;
    }

    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
       // SpecificCT_Parameters.Instance.Shutdown();
    }

    private void btnClear_Click(object sender, EventArgs e)
    {
        rtbMessages.Clear();
    }

    private async void btnStart_Click(object sender, EventArgs e)
    {
        if (camera != null)
        {
            if (!camera.IsStreaming)
            {
                try
                {
                    await camera.StartStreamAsync("10.0.1.177").ConfigureAwait(false);
                }catch(Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

                // bool isStarted = await camera.StartStreamAsync();
             //   await camera.StartStreamAsync().ConfigureAwait(false);
            //bool isStarted = await camera.StartStreamAsync().ConfigureAwait(false);
        }
    }

    private async void btnStop_ClickAsync(object sender, EventArgs e)
    {
        if (camera != null)
        {
            if (camera.IsStreaming)
            {
                await camera.StopStream().ConfigureAwait(false);// .StopStream().ConfigureAwait(false);
            }

            // bool isStarted = await camera.StartStreamAsync();
            //   await camera.StartStreamAsync().ConfigureAwait(false);
            //bool isStarted = await camera.StartStreamAsync().ConfigureAwait(false);
        }
    }
}

Da: Touseef Elahi @.> Inviato: lunedì 22 agosto 2022 14:43 A: Touseefelahi/GigeVision @.> Cc: Luca Snaidero @.>; Mention @.> Oggetto: Re: [Touseefelahi/GigeVision] Baumer camera integration (Issue #52)

@lsnaiderohttps://github.com/lsnaidero and did you call this start stream method? (Mentioned in the readme)

//For multiple interfaces you can define the Rx IP as: (In this example 192.168.10.221 is the PC IP) bool isStarted = await camera.StartStreamAsync("192.168.10.221").ConfigureAwait(false);

— Reply to this email directly, view it on GitHubhttps://github.com/Touseefelahi/GigeVision/issues/52#issuecomment-1222306734, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A2USKUH5EE3JYQCO6GQNO4TV2NYXBANCNFSM57HLGTYA. You are receiving this because you were mentioned.Message ID: @.@.>>

lsnaidero avatar Aug 22 '22 12:08 lsnaidero

Do you get any device in the discovery by calling get all gige devices function?

Touseefelahi avatar Aug 22 '22 16:08 Touseefelahi

Hi I changed the code in order to search the devices gige NOTE 1: 10.0.5.188 is my pc ip NOTE 2: I changed the function to search the device like following raw:

gvcp.GetAllGigeDevicesInNetworkAsnyc("10.0.5.188").ConfigureAwait(false); (in effect I added the .ConfigureAwait(false); to the previous version )

With this implementation I obtained a list with my device present.

Anyway I continue to not obtain frame from the stream….

Follow my actual code

Any suggest will be very appreciated.

Thank a lot for your support Best regards Luca

public Form1() { InitializeComponent(); }

    Gvcp gvcp = null;
    Camera camera = null;
    Dictionary<string, string> registers = null;
    List<CameraInformation> devices = null;
    private void button1_Click(object sender, EventArgs e)
    {

        setup();
    }

    private async void setup()
    {
        gvcp = new Gvcp();
        camera = new Camera(gvcp);
       devices = await gvcp.GetAllGigeDevicesInNetworkAsnyc("10.0.5.188").ConfigureAwait(false);

        if (devices.Count > 0)
        {
            camera.IP = devices.FirstOrDefault()?.IP;
        }
        camera.FrameReady += FrameReady;
    }

    private void FrameReady(object sender, byte[] e)
    {
        Console.WriteLine("FrameReady");
    }
    private async void start()
    {
        await camera.StartStreamAsync("10.0.5.188").ConfigureAwait(false);
    }
    private void button2_Click(object sender, EventArgs e)
    {
        start();
    }

Da: Touseef Elahi @.> Inviato: lunedì 22 agosto 2022 18:55 A: Touseefelahi/GigeVision @.> Cc: Luca Snaidero @.>; Mention @.> Oggetto: Re: [Touseefelahi/GigeVision] Baumer camera integration (Issue #52)

Do you get any device in the discovery by calling get all gige devices function?

— Reply to this email directly, view it on GitHubhttps://github.com/Touseefelahi/GigeVision/issues/52#issuecomment-1222634521, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A2USKUAPZXIYNZM7VBLAQCDV2OWF5ANCNFSM57HLGTYA. You are receiving this because you were mentioned.Message ID: @.@.>>

lsnaidero avatar Aug 23 '22 06:08 lsnaidero

@lsnaidero what is the status of StartStreamAsync method? it returns Status/bool

Touseefelahi avatar Aug 23 '22 06:08 Touseefelahi

StartStreamAsync method returns False

Da: Touseef Elahi @.> Inviato: martedì 23 agosto 2022 08:27 A: Touseefelahi/GigeVision @.> Cc: Luca Snaidero @.>; Mention @.> Oggetto: Re: [Touseefelahi/GigeVision] Baumer camera integration (Issue #52)

@lsnaiderohttps://github.com/lsnaidero what is the status of StartStreamAsync method? it returns Status/bool

— Reply to this email directly, view it on GitHubhttps://github.com/Touseefelahi/GigeVision/issues/52#issuecomment-1223607909, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A2USKUCIMXJSPHL33GQ4R2DV2RVL5ANCNFSM57HLGTYA. You are receiving this because you were mentioned.Message ID: @.@.>>

lsnaidero avatar Aug 23 '22 06:08 lsnaidero

@lsnaidero you can also listen to the updates from the Camera class by listening to Updates Event, the same way as the FrameReady Event, it might give us some clue about what's going on.

And there is a very good utility Wireshark, it can give us a very clear indication about the problem. I suggest you install Wireshark so that we can know what is the status of each command.

Touseefelahi avatar Aug 23 '22 06:08 Touseefelahi

Hi touseef Sorry , I’m following others projects so I’m was late to execute the test you suggest

Once I attached to the event Updates (like following code)

camera.Updates += UpdatesEvent;

now with the bool bREs=await camera.StartStreamAsync("10.0.5.188").ConfigureAwait(false); I obtain the following message from the event :

Specified argument was out of the range of valid values.

And the frame is not sent

Da: Touseef Elahi @.> Inviato: martedì 23 agosto 2022 08:32 A: Touseefelahi/GigeVision @.> Cc: Luca Snaidero @.>; Mention @.> Oggetto: Re: [Touseefelahi/GigeVision] Baumer camera integration (Issue #52)

@lsnaiderohttps://github.com/lsnaidero you can also listen to the updates from the Camera class by listening to Updates Event, the same way as the FrameReady Event, it might give us some clue about what's going on.

And there is a very good utility Wireshark, it can give us a very clear indication about the problem. I suggest you install Wireshark so that we can know what is the status of each command.

— Reply to this email directly, view it on GitHubhttps://github.com/Touseefelahi/GigeVision/issues/52#issuecomment-1223612298, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A2USKUDC5SOZFN2WD3MEZFDV2RV7DANCNFSM57HLGTYA. You are receiving this because you were mentioned.Message ID: @.@.>>

lsnaidero avatar Oct 11 '22 07:10 lsnaidero

@lsnaidero kindly, synchronize with the latest commit and try again. And check with Wireshark, if the stream is actually started or not. It seems like there is an issue with some array bound, but I am not certain.

Easy way would be to clone the project and run using the sample application and see where it is causing the issue

Touseefelahi avatar Oct 11 '22 11:10 Touseefelahi