Fastest way to load all unique cameras

For our plugin integration we need to load all available camera devices within the system.

Currently we are using a stack based approach using the Configuration API, similar to what is described here:

https://developer.milestonesys.com/s/question/0D53X00006Sow5dSAB/how-to-get-the-available-cameras

For the most part it works fine, however we have clients with over a thousand cameras where the load time sometimes can take over a minute. Also having a lot of camera groups, where a single camera can appear in many groups makes it worse.

Is there a better approach to load all unique cameras? Loading the name and ID of the object would be sufficient for our use case. Everything else could be loaded on demand.

I have an idea.

What you do is to take all camera groups and go through them, you will not get cameras that are not in any group, and you will get cameras multiple times if in multiple groups but filter duplicates out.

What i propose is that you instead take all recording servers, then take all hardware, then take all cameras. The advantage is that you will never get the same camera twice, and even if a camera is not in any camera group you will still get it.

It would look something like..

using VideoOS.Platform;
using VideoOS.Platform.ConfigurationItems;
 
private void FindAllCameras()
{           
	ManagementServer mgt = new ManagementServer(EnvironmentManager.Instance.MasterSite.ServerId);
	foreach (var rec in mgt.RecordingServerFolder.RecordingServers)
	{
		foreach (var hard in rec.HardwareFolder.Hardwares)
		{
			foreach (var cam in hard.CameraFolder.Cameras)
			{
				label1.Text += cam.Name + Environment.NewLine;
			}
		}
	}
}

I am in doubt, you say you use the Configuration API, and then this fits. The link you gave links to a routine that uses the MIP configuration instead, and if that is what you want, then this might not fit. Confusing about to different configurations. Let me know if you need the MIP configuration instead then I can come with another answer.

Thanks Bo,

I guess I was a bit confused with the nomenclature of the different APIs.

But your approach works a lot faster. On our customer system it decreased the load time from around 70-80 seconds to about 15, which is much more acceptable.

Thank you!

Thank you for the feedback, I am glad it works nicely for you.