# Getting Started with CVB.Net

**URL:** <https://forum.commonvisionblox.com/t/getting-started-with-cvb-net/246>\
**Category:** .Net API\
**Tags:** csharp, tutorial\
**Created:** [September 9, 2019, 10:00pm UTC](https://forum.commonvisionblox.com/t/getting-started-with-cvb-net/246 "2019-09-09T22:00:00Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![parsd](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/parsd/32/7_2.png) [@parsd](https://forum.commonvisionblox.com/u/parsd)\
**Post date:** [September 11, 2019, 11:54am UTC](https://forum.commonvisionblox.com/t/getting-started-with-cvb-net/246/6 "2019-09-11T11:54:42Z")

</div>

# Acquire from a Camera (Console)

In general this is similar to the things we have done so far:

> [@parsd](#):
>
> # Acquire Images from a Stream (Console)

You have two general options on how to open devices:

1. `DeviceFactory.Open` and its related methods to open a _vin-driver_.
2. `DeviceFactory.Discover` for GenICam GenTL based drivers (like _GigE Vision_ or _USB3 Vision_)

> **Don't have a camera?**
>
> Then let’s simulate one with the :cvb: _GigE Vision Server_! (You need :cvb: full install – not CameraSuite for that.)
> 
> Depending on your operating system find the
> 
> > GEVServer \> _C# GEVServer Example_
> 
> This can be found either directly in the start menu (e.g. _Windows 7_) or via the _Tutorials_ link (e.g. _Windows 10_).
> 
> When starting the app select one of the available IP addresses (best one not in your company network to keep your admins on your good side 😉). Also select the _Socket Driver_ instead of the _Filter Driver_ as we want to do loop-back (communication on the same machine). Then hit _Start_ and you have a camera.
> 
> If you have no available IP address (e.g. offline usage) or no private one you can install a virtual network adapter as described [here](https://gist.github.com/parsd/4fa006133499641089b54aa78adf29a1).

## Case 1: Load Vin-Driver

For configuration I just assume you use a GenICam based device (like _GEV_, _U3V_). For other vin-drivers please consult the driver’s documentation on how to configure them. You can use the :cvb: default way of configuring your devices via the _GenICamBrowser_ or the _Common Vision Blox Management Console_.

> **Configure for local GEV Server**
>
> When you want to acquire images from a locally running _GEV Server_, you also need to set the used driver to _Socket_. This can currently only be done in the _Common Vision Blox Management Console_ or the _GEV Config Manager_. For the _Management Console_ you find this setting in the camera’s context menu.

To access these configured devices you can call simply call

> `Device firstDevice = DeviceFactory.Open("GenICam.vin");`

to open the _firstDevice_. Depending on the driver you can also access other configured cameras like this:

> `Device secondDevice = DeviceFactory.OpenPort("GenICam.vin", 1);`

(It is zero-based indexing.)

## Case 2: Discover devices

This so far only works for _GenICam GenTL_ based devices (like _GEV_, _U3V_). Here you don’t need the additional configuration step. Simply call

> `DiscoveryInformationList foundDevices = DeviceFactory.Discover();`

to find all available devices in your environment (this is the same as the output in the _Management Console_).

> **Discover for local GEV Server**
>
> For this you need to change the default filter:
> 
> > `var foundDevices = DeviceFatory.Discover(DiscoverFlags.IgnoreVins | DiscoverFlags.IgnoreGevFD);`

Let’s assume we found at least one device (`foundDevices.Count > 0`), we can open it like this:

> `Device device = DeviceFactory.Open(foundDevices[0]);`

## Streaming

As we have a `Device` again, we can do the streaming like with the video file. The only difference now is that we just have an (endless) `Stream` instead of an `IndexedStream`:

```auto
Stream stream = device.Stream;

stream.Start();
try
{
  for (int i = 0; i < 10; i++)
  {
    using (StreamImage image = stream.Wait())
    {
      // Processing...
    }
  }
}
finally
{
  stream.Stop();
}

```

Looks nearly the same except the `Stream` type and the loop over 10 images.

---

_[View the full topic](https://forum.commonvisionblox.com/t/getting-started-with-cvb-net/246)._
