Problem when discovering cameras

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 :

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 :

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

I get two pictures to help :

and

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.

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

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

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 :slight_smile:

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

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