I am writing an application (Cvb++, Qt, GenICam) and I would like to present a list of cameras to the user so that the user can chose one of the detected cameras and use it.
Obtaining a list of cameras via Cvb::DeviceFactory::Discover() works nicely; however, I did not find a way to Cvb::DeviceFactory::Open() a specific camera detected.
Is there a way to obtain the Vin driver path (optional, I could of course provide this) and open one of the detected camaras (e.g. via serial number, Id, …)?
Alternatively, is there a way to list the cameras on a vin driver and select one of them?
I would like to avoid having to use an external tool to select the camera to be used.
you can open a discovered device info by calling:
auto device = Cvb::DeviceFactory::Open(info.AccessToken());
This opens a device (GenICam.vin) directly via the access token. No preconfiguration via the GenICam.ini is necessary.
I was wondering why DO_DISCOVER_INFO_ACCESS_TOKEN was missing from DiscoveryProperties, but of course that´s the reason - it´s in a separate function.
we put it in a function as this property is always available and needed most .
One more question in this context: how do I close a device?
Discover() works nicely as long as the camera has not been Open()ed, but Discover() obviously cannot access open devices.
P.S.: pDevice.reset() seems to work, but is this safe?
yes that is safe. It is the intended way (or let the
std::shared_ptr run out of scope).
But keep in mind that you have shared ownership with the returned device (
std::shared_ptr<Cvb::Device>). That means if you have stored the device
std::shared_ptr in multiple places (e.g. objects), the
Device is unloaded when the last
.reset or runs out of scope.
Regarding inaccessible devices (e.g. opened): if the transport technology supports it,
.Discover() filters these out. You can still show them by providing the
DiscoverFlags::IncludeInaccessible to the
.Discover() call. But you still won’t be able to open the device in a different process.
Also note that if you simply call
.Discover(), it is the same as calling
.Discover(DiscoverFlags::IgnoreVins | DiscoverFlags::IgnoreGevSD). This is the same as the default Management Console/GenICam Browser output.
Ok, that´s fine then - I can keep track of the number of references to the pointer, I was just afraid there might be copies stored somewhere in the Cvb++ part.
Thanks for the answer!
We only keep weak references (
std::weak_ptr). Opening the same device returns the same