# Problem when discovering cameras

**URL:** <https://forum.commonvisionblox.com/t/problem-when-discovering-cameras/2284>\
**Category:** C++ API\
**Created:** [December 1, 2024, 11:01pm UTC](https://forum.commonvisionblox.com/t/problem-when-discovering-cameras/2284 "2024-12-01T23:01:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AxelDosSantosDoAlto](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@AxelDosSantosDoAlto](https://forum.commonvisionblox.com/u/AxelDosSantosDoAlto)\
**Post date:** [December 1, 2024, 11:01pm UTC](https://forum.commonvisionblox.com/t/problem-when-discovering-cameras/2284/1 "2024-12-01T23:01:52Z")

</div>

Hello everyone,

I used the DeviceFactory Discover method to get a list of all the camera connected to the computer, so that we can dynamically choose the camera that we want to use when our software is setup on a new Windows 11 64 bits computer on our system.

See below my code :

```auto
static std::vector<CCvbGeniCamData> GetDataFromDiscovery(Cvb::DiscoverFlags flags_to_use)
	{
		auto discoveryInformations = Cvb::DeviceFactory::Discover(flags_to_use);
		auto cameratInformations = std::vector<CCvbGeniCamData>();
		for (size_t i = 0; i < discoveryInformations.capacity(); i++)
		{
			std::string deviceData = Cvb::String();
			CCvbGeniCamData data;
			try
			{
				data.DeviceData.DeviceAccessStatus = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::DeviceAccessStatus, deviceData) ? deviceData : "n\\a";
				data.DeviceData.DeviceId = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::DeviceId, deviceData) ? deviceData : "n\\a";
				data.DeviceData.DeviceIP = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::DeviceIP, deviceData) ? deviceData : "n\\a";
				data.DeviceData.DeviceMac = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::DeviceMac, deviceData) ? deviceData : "n\\a";
				data.DeviceData.DeviceModel = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::DeviceModel, deviceData) ? deviceData : "n\\a";
				data.DeviceData.DeviceSerialNumber = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::DeviceSerialNumber, deviceData) ? deviceData : "n\\a";
				data.DeviceData.DeviceSubnetMask = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::DeviceSubnetMask, deviceData) ? deviceData : "n\\a";
				data.DeviceData.DeviceTransportLayerType = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::DeviceTransportLayerType, deviceData) ? deviceData : "n\\a";
				data.DeviceData.DeviceUsbProductId = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::DeviceUsbProductId, deviceData) ? deviceData : "n\\a";
				data.DeviceData.DeviceUsbVendorId = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::DeviceUsbVendorId, deviceData) ? deviceData : "n\\a";
				data.DeviceData.DeviceUsername = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::DeviceUsername, deviceData) ? deviceData : "n\\a";
				data.DeviceData.DeviceVendor = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::DeviceVendor, deviceData) ? deviceData : "n\\a";

				data.DeviceDataTransport.TransportLayerId = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::TransportLayerId, deviceData) ? deviceData : "n\\a";
				data.DeviceDataTransport.TransportLayerPath = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::TransportLayerPath, deviceData) ? deviceData : "n\\a";
				data.DeviceDataTransport.TransportLayerVendor = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::TransportLayerVendor, deviceData) ? deviceData : "n\\a";

				data.InformationInterface.InterfaceDisplayName = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::InterfaceDisplayName, deviceData) ? deviceData : "n\\a";
				data.InformationInterface.InterfaceDriverType = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::InterfaceDriverType, deviceData) ? deviceData : "n\\a";
				data.InformationInterface.InterfaceId = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::InterfaceId, deviceData) ? deviceData : "n\\a";
				data.InformationInterface.InterfaceMac = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::InterfaceMac, deviceData) ? deviceData : "n\\a";
				data.InformationInterface.InterfaceSubNetList = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::InterfaceSubNetList, deviceData) ? deviceData : "n\\a";
				data.InformationInterface.InterfaceTLType = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::InterfaceTLType, deviceData) ? deviceData : "n\\a";

				data.UsbPortPath = discoveryInformations[i].TryGetProperty(Cvb::DiscoveryProperties::UsbPortPath, deviceData) ? deviceData : "n\\a";
				data.AccessToken = discoveryInformations[i].AccessToken();

				switch (discoveryInformations[i].DiscoveryLayer())
				{
				case Cvb::ModuleLayer::System: data.ModuleLayer = "System"; break;
				case Cvb::ModuleLayer::TransportLayerDevice: data.ModuleLayer = "TransportLayerDevice"; break;
				case Cvb::ModuleLayer::TransportLayerInterface: data.ModuleLayer = "TransportLayerInterface"; break;
				case Cvb::ModuleLayer::TransportLayerStream: data.ModuleLayer = "TransportLayerStream"; break;
				case Cvb::ModuleLayer::TransportLayerSystem: data.ModuleLayer = "TransportLayerSystem"; break;
				case Cvb::ModuleLayer::Unknown: data.ModuleLayer = "Unknown"; break;
				case Cvb::ModuleLayer::Vin: data.ModuleLayer = "Vin"; break;
				default:
					break;
				}
			}
			catch (const std::exception& exce)
			{
				std::string error = exce.what();
			}

			cameratInformations.push_back(data);
		}
		return cameratInformations;
	}

```

I get a lot of element from the discoveryInformations, and somehow I get sometime a device that return an c++ exception at the line :

```auto
data.AccessToken = discoveryInformations[i].AccessToken();

```

I get two pictures to help :

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/2X/7/72702d923afecae7c47240fd227cf47b4faedaa5.png)

and

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/2X/3/31c3506c3b24c4136b0c3a6cede17ced619cef78.png)

Do you know what can do that ? I try this code on 6 software-setup-the-same computers, all with a recent version of CVB 14.01.01, and two of them have this error.

---

<div class="post-metadata">

**Author:** ![Chris](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/chris/32/1154_2.png) [@Chris](https://forum.commonvisionblox.com/u/Chris)\
**Post date:** [December 3, 2024, 8:07am UTC](https://forum.commonvisionblox.com/t/problem-when-discovering-cameras/2284/2 "2024-12-03T08:07:24Z")

</div>

Hi @AxelDosSantosDoAlto ,

we had a Bug in the past where we got an exception during discovery, when the OS was set to French.  
This was due to the accent aigu used in the string of the underlaying interface “Contrôleur d’hôte compatible xHCI USB”

This bug should have been fixed but maybe it found its way back into CVB.  
Please check the working machines against the non working ones and compare the languages of the OS.

Let me know if this was the problem so I can forward this to dev for fixing if this is still the case.

Cheers  
Chris

---

<div class="post-metadata">

**Author:** ![AxelDosSantosDoAlto](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@AxelDosSantosDoAlto](https://forum.commonvisionblox.com/u/AxelDosSantosDoAlto)\
**Post date:** [December 6, 2024, 8:59am UTC](https://forum.commonvisionblox.com/t/problem-when-discovering-cameras/2284/3 "2024-12-06T08:59:54Z")

</div>

Hello Chris,

Thanks for you message.

The crash arrived when I used this line :  
data.AccessToken = discoveryInformations[i].AccessToken();  
where data.AccessToken is a std::string, to know if the camera is available or not.

I think it is because the camera seen by the discover is not the a true camera. May be my way to get information isn’t very good ?

I do not have a problem with “Contrôleur d’hôte compatible xHCI USB”.

Cheers,  
Axel

---

<div class="post-metadata">

**Author:** ![Chris](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/chris/32/1154_2.png) [@Chris](https://forum.commonvisionblox.com/u/Chris)\
**Post date:** [December 6, 2024, 9:16am UTC](https://forum.commonvisionblox.com/t/problem-when-discovering-cameras/2284/4 "2024-12-06T09:16:16Z")

</div>

The 6 machines where the code is working, which language does the OS have there?  
The 2 machines where it is not working, whats the OS language there?

I still think this might be our problem really 🙂

---

<div class="post-metadata">

**Author:** ![AxelDosSantosDoAlto](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@AxelDosSantosDoAlto](https://forum.commonvisionblox.com/u/AxelDosSantosDoAlto)\
**Post date:** [December 6, 2024, 9:53am UTC](https://forum.commonvisionblox.com/t/problem-when-discovering-cameras/2284/5 "2024-12-06T09:53:38Z")

</div>

French for the two where the problem appeared, for the others, I don’t know.

How can I be suûre that it’s this problem ? AN=bcorrect this ?

Axel

---

<div class="post-metadata">

**Author:** ![Chris](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/chris/32/1154_2.png) [@Chris](https://forum.commonvisionblox.com/u/Chris)\
**Post date:** [December 6, 2024, 11:48am UTC](https://forum.commonvisionblox.com/t/problem-when-discovering-cameras/2284/6 "2024-12-06T11:48:05Z")

</div>

Hi Axel,

you can correct this by either switching the language of the OS or update to the latest CVB Version.

For the unlikely case that the problem still occurs with the latest CVB Version, let me know.

Cheers  
Chris
