Esempio n. 1
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (cam != null)
     {
         cam.DeInit();
         cam.Dispose();
     }
     if (camList.Count != 0)
     {
         camList.Clear();
     }
     system.Dispose();
     Console.WriteLine("\nDone!");
 }
Esempio n. 2
0
 public void Disconnect()
 {
     try
     {
         if (camera != null)
         {
             camera.Dispose();
             //camera.EndAcquisition();
             //camera.UnregisterEvent(imageEventListener);
             //camera.DeInit();
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("PtGrey Disconnect : " + ex.Message);
     }
     finally
     {
     }
 }
Esempio n. 3
0
        // This function queries an interface for its cameras and then prints
        // out device information.
        int QueryInterface(IManagedInterface managedInterface)
        {
            int result = 0;

            try {
                //
                // Retrieve TL nodemap from interface
                //
                // *** NOTES ***
                // Each interface has a nodemap that can be retrieved in order
                // to access information about the interface itself, any devices
                // connected, or addressing information if applicable.
                //
                INodeMap nodeMapInterface = managedInterface.GetTLNodeMap();

                //
                // Print interface display name
                //
                // *** NOTES ***
                // Grabbing node information requires first retrieving the node
                // and then retrieving its information. There are two things to
                // keep in mind. First, a node is distinguished by type, which
                // is related to its value's data type. Second, nodes should be
                // checked for availability and readability/writability prior to
                // making an attempt to read from or write to them.
                //
                IString iInterfaceDisplayName = nodeMapInterface.GetNode <IString>("InterfaceDisplayName");

                if (iInterfaceDisplayName != null && iInterfaceDisplayName.IsReadable)
                {
                    string interfaceDisplayName = iInterfaceDisplayName.Value;

                    Console.WriteLine("{0}", interfaceDisplayName);
                }
                else
                {
                    Console.WriteLine("Interface display name not readable");
                }

                //
                // Update list of cameras on the interface
                //
                // *** NOTES ***
                // Updating the cameras on each interface is especially important
                // if there has been any device arrivals or removals since the
                // last time UpdateCameras() was called.
                //
                managedInterface.UpdateCameras();

                //
                // Retrieve list of cameras from the interface
                //
                // *** NOTES ***
                // Camera lists can be retrieved from an interface or the system
                // object. Camera lists retrieved from an interface, such as this
                // one, only return cameras attached on that specific interface
                // while camera lists retrieved from system returns all cameras
                // on all interfaces.
                //
                // *** LATER ***
                // Camera lists must be cleared manually. This must be done
                // prior to releasing the system and while the camera list is
                // still in scope.
                //
                List <IManagedCamera> camList = managedInterface.GetCameras();

                // Return if no cameras detected
                if (camList.Count == 0)
                {
                    Console.WriteLine("\tNo devices detected.\n");
                    return(0);
                }

                // Print device vendor and model name for each camera on the
                // interface
                for (int i = 0; i < camList.Count; i++)
                {
                    //
                    // Select camera
                    //
                    // *** NOTES ***
                    // Each camera is retrieved from a camera list with an index.
                    // If the index is out of range, an exception is thrown.
                    //
                    IManagedCamera cam = camList[i];

                    // Retrieve TL device nodemap; please see NodeMapInfo_CSharp
                    // example for additional information on TL device nodemaps
                    INodeMap nodeMapTLDevice = cam.GetTLDeviceNodeMap();

                    Console.Write("\tDevice {0} ", i);

                    // Print device vendor name and device model name
                    IString iDeviceVendorName = nodeMapTLDevice.GetNode <IString>("DeviceVendorName");

                    if (iDeviceVendorName != null && iDeviceVendorName.IsReadable)
                    {
                        String deviceVendorName = iDeviceVendorName.Value;

                        Console.Write("{0} ", deviceVendorName);
                    }

                    IString iDeviceModelName = nodeMapTLDevice.GetNode <IString>("DeviceModelName");

                    if (iDeviceModelName != null && iDeviceModelName.IsReadable)
                    {
                        String deviceModelName = iDeviceModelName.Value;

                        Console.WriteLine("{0}\n", deviceModelName);
                    }

                    // Dispose of managed camera
                    cam.Dispose();

                    //
                    // Clear camera list before losing scope
                    //
                    // *** NOTES ***
                    // If a camera list (or an interface list) is not cleaned up
                    // manually, the system will do so when the system is
                    // released.
                    //
                    camList.Clear();
                }
            } catch (SpinnakerException ex) {
                Console.WriteLine("Error " + ex.Message);
                result = -1;
            }

            return(result);
        }