// Example entry points; this function sets up the system and retrieves // interfaces to retrieves interfaces for the example. public static int Start() { int result = 0; Program program = new Program(); // // Retrieve singleton reference to system object // // *** NOTES *** // Everything originates with the system object. It is important to // notice that it has a singleton implementation, so it is impossible // to have multiple system objects at the same time. // // *** LATER *** // The system object should be cleared prior to program completion. // If not released explicitly, it will be released automatically // when all system objects go out of scope. // ManagedSystem system = new ManagedSystem(); // Print out current library version LibraryVersion spinVersion = system.GetLibraryVersion(); Console.WriteLine("Spinnaker library version: {0}.{1}.{2}.{3}\n\n", spinVersion.major, spinVersion.minor, spinVersion.type, spinVersion.build); // // Retrieve list of interfaces from the system // // *** NOTES *** // Interface lists are retrieved from the system object. // // *** LATER *** // Interface lists are constructed using list objects of // IManagedInterface objects. Lists are native to C# and must be // cleared after use. // List <IManagedInterface> interfaceList = system.GetInterfaces(); Console.WriteLine("Number of interfaces detected: {0}\n", interfaceList.Count); // // Retrieve list of cameras from the system // // *** NOTES *** // Camera lists are retrieved from the system object. // // *** LATER *** // Camera lists are constructed using list objects of IManagedCamera // objects. Lists are native to C# and must be cleared after use. // List <IManagedCamera> camList = system.GetCameras(); Console.WriteLine("Number of cameras detected: {0}\n", camList.Count); // Finish if there are no cameras if (camList.Count == 0 || interfaceList.Count == 0) { // Clear camera list before releasing system camList.Clear(); // Clear interface list before releasing system interfaceList.Clear(); // Release system system.Dispose(); Console.WriteLine("Not enough cameras!"); Console.WriteLine("Done! Press Enter to exit..."); Console.ReadLine(); return(-1); } Console.WriteLine("\n*** QUERYING INTERFACES ***\n"); // // Run example on each interface // // *** NOTES *** // Managed interfaces will need to be disposed of after use in order // to fully clean up. Using-statements help ensure that this is taken // care of; otherwise, interfaces can be disposed of manually by calling // Dispose(). // foreach (IManagedInterface managedInterface in interfaceList) { using (managedInterface) { try { // Run example result = result | program.QueryInterface(managedInterface); } catch (SpinnakerException ex) { Console.WriteLine("Error: {0}", ex.Message); result = -1; } } } // // Clear camera list before releasing system // // *** NOTES *** // If a camera list is not cleaned up // manually, the system will do so when System.Dispose() is // called. // camList.Clear(); // // Clear interface list before releasing system // // *** NOTES *** // If an interface list is not cleaned up // manually, the system will do so when System.Dispose() is // called. // interfaceList.Clear(); // // Release system // // *** NOTES *** // The system should be released, but if it is not, it will do so // itself. It is often at the release of the system (whether manual // or automatic) that unbroken references and still registered // events will throw an exception. // system.Dispose(); Console.WriteLine("\nDone!"); //Console.ReadLine(); return(result); }