Connect to Basler Camera in C#

728 Views Asked by At

I want to connect to my Basler ace acA1440-73gm camera using C#. I will be using this in a WPF application in .NET7.0.

Which Nuget Packages to download and how to connect to the camera?

I have installed pylon runtime version 7.4.0.

I tried adding these two nuget packages:

  1. Basler.Pylon.NET.x64, Version= 7.4.0.38864
  2. Basler.Pylon.x64, Version= 4.2.1.4845

For the first one it says "The type or namespace name 'Basler' could not be found (are you missing a using directive or an assembly reference?)" when I do using Basler.Pylon;.

And for second one it gives error "External component has thrown an exception" when I do Camera camera = new Camera().

I am able to connect to camera using pylon Viewer and in python as well.

I have gone through the documentation and in samples they had using Basler.Pylon; so I am not sure if the documentation is updated for C#?

1

There are 1 best solutions below

1
On BEST ANSWER

As far as I can tell, the basler.pylon.net.x64 nuget packet does not actually include the required dll. So I'm not sure what purpose it has.

The file you need is basler.pylon.dll and can be found in "\Basler\pylon 7\Development\Assemblies\Basler.Pylon\x64" . Add this as a file-reference to your project. Check that this file is copied to the bin-folder when compiling, and that using Basler.Pylon; no longer give an error.

That should be enough if you ensure the full-featured pylon package is installed where the application is used. It is also possible to install a smaller packet that only contain the pylon filter driver (if a ethernet camera), and deploy the rest of the required dlls yourself. But refer to the pylon documentation details for this.

Also note that you are probably using a genicam/gigE vision/USB camera, since this is a standard, any non-vendor locked library should work.