Ejemplo n.º 1
0
        public static void CloseOryxCamera(IManagedCamera managedCamera, INodeMap nodeMap, int camNumber, CloseCameraMethod closeMethod)
        {
            if (!managedCamera.IsInitialized())
            {
                Console.WriteLine("Camera number {0} not initialized. Cannot execute DeviceReset or FactoryReset command", camNumber.ToString());
                return;
            }

            if (managedCamera.IsStreaming())
            {
                managedCamera.EndAcquisition();
                Console.WriteLine("EndAcquisition executed from CloseOryxCamera block on camera {0}", camNumber.ToString());
            }

            if (closeMethod == CloseCameraMethod.DeInit)
            {
                managedCamera.DeInit();
                Console.WriteLine("Camera number {0} deinitialized.", camNumber.ToString());
            }
            else if (closeMethod == CloseCameraMethod.DeInitAndDeviceReset)
            {
                nodeMap.GetNode <ICommand>("DeviceReset").Execute();
                Console.WriteLine("DeviceReset command executed on camera number {0}.", camNumber.ToString());
            }
            else if (closeMethod == CloseCameraMethod.DeInitAndFactoryReset)
            {
                nodeMap.GetNode <ICommand>("FactoryReset").Execute();
                Console.WriteLine("FactoryReset command executed on camera number {0}.", camNumber.ToString());
            }
        }
Ejemplo n.º 2
0
        // This function acts as the body of the example; please see
        // NodeMapInfo_CSharp example for more in-depth comments on setting up
        // cameras.
        public int RunSingleCamera(IManagedCamera cam)
        {
            int result = 0;

            try
            {
                // Retrieve TL device nodemap and print device information
                INodeMap nodeMapTLDevice = cam.GetTLDeviceNodeMap();

                result = PrintDeviceInfo(nodeMapTLDevice);

                // Initialize camera
                cam.Init();

                // Retrieve GenICam nodemap
                INodeMap nodeMap = cam.GetNodeMap();

                // Acquire images
                result = result | AcquireImages(cam, nodeMap, nodeMapTLDevice);

                // Deinitialize camera
                cam.DeInit();
            }
            catch (SpinnakerException ex)
            {
                writeLog(String.Format("Error: {0}\n", ex.Message));
                result = -1;
            }

            return(result);
        }
Ejemplo n.º 3
0
 public override void Deinit(int index = 0)
 {
     try
     {
         if (m_Camera != null)
         {
             m_Camera.DeInit();
         }
     }
     catch (Exception ex)
     {
         LogHelper.AppLoger.Error(ex);
     }
 }
Ejemplo n.º 4
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!");
 }
Ejemplo n.º 5
0
 public override void DisConnect()
 {
     try
     {
         if (camera != null)
         {
             StopCapture();
             camera.UnregisterEvent(imageEventListener);
             camera.DeInit();
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("PtGrey Disconnect : " + ex.Message);
     }
 }
Ejemplo n.º 6
0
 public override void DisConnect()
 {
     try
     {
         if (camera != null)
         {
             //camera.StopCapture();
             //camera.Disconnect();
             camera.EndAcquisition();
             camera.DeInit();
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("PtGrey Disconnect : " + ex.Message);
     }
     finally
     {
     }
 }
Ejemplo n.º 7
0
        // This function acts as the body of the example; please see
        // NodeMapInfo_CSharp example for more in-depth comments on setting up
        // cameras.
        int RunSingleCamera(IManagedCamera cam)
        {
            int result = 0;
            int err    = 0;

            try {
                // Retrieve TL device nodemap and print device information
                INodeMap nodeMapTLDevice = cam.GetTLDeviceNodeMap();

                result = PrintDeviceInfo(nodeMapTLDevice);

                // Initialize camera
                cam.Init();

                // Retrieve GenICam nodemap
                INodeMap nodeMap = cam.GetNodeMap();

                // Acquire images
                List <IManagedImage> images = new List <IManagedImage>();

                err = result | AcquireImages(cam, nodeMap, ref images);
                if (err < 0)
                {
                    return(err);
                }

                // Create video
                result = result | SaveListToVideo(nodeMap, nodeMapTLDevice, ref images);

                // Deinitialize camera
                cam.DeInit();
            } catch (SpinnakerException ex) {
                Console.WriteLine("Error: {0}", ex.Message);
                result = -1;
            }

            return(result);
        }
Ejemplo n.º 8
0
        public IManagedImage RetrieveMonoImage()
        {
            IManagedImage imgResult = null;

            // Retrieve singleton reference to system object
            ManagedSystem system = new ManagedSystem();

            // Retrieve list of cameras from the system
            IList <IManagedCamera> camList = system.GetCameras();

            if (camList.Count < 1)
            {
                writeLog(String.Format("No camera detected. Aborted.\n\n"));
                return(null);
            }
            else
            {
                writeLog(String.Format("Number of cameras detected: {0}\n\n", camList.Count));
            }
            // Use the first camera
            using (camList[0])
            {
                writeLog(String.Format("Running example for the 1st camera...\n"));

                IManagedCamera cam = camList[0];

                try
                {
                    // Run for a camera

                    // Retrieve TL device nodemap and print device information
                    INodeMap nodeMapTLDevice = cam.GetTLDeviceNodeMap();

                    PrintDeviceInfo(nodeMapTLDevice);

                    // Initialize camera
                    cam.Init();

                    // Retrieve GenICam nodemap
                    INodeMap nodeMap = cam.GetNodeMap();

                    /*****  Acquire single BW image from the camera  *****/

                    writeLog(String.Format("\n*** BW IMAGE ACQUISITION ***\n\n"));
                    SetNodeMapItem(nodeMap, "AcquisitionMode", "Continuous");
                    cam.BeginAcquisition();
                    using (IManagedImage rawImage = cam.GetNextImage())
                    {
                        if (rawImage.IsIncomplete)
                        {
                            writeLog(String.Format(
                                         "Image incomplete with image status {0}...\n", rawImage.ImageStatus));
                            imgResult = null;
                        }
                        else
                        {
                            // TODO: Need to return the acquired rawImage here.
                            //IManagedImage monoImage = rawImage.Convert(
                            //    PixelFormatEnums.Mono16, ColorProcessingAlgorithm.EDGE_SENSING);
                            IManagedImage monoImage = rawImage.Convert(PixelFormatEnums.Mono8);
                            imgResult = monoImage;
                        }
                    }
                    cam.EndAcquisition();

                    /*****  Acquiring Complete  *****/

                    // Deinitialize camera
                    cam.DeInit();
                }
                catch (SpinnakerException ex)
                {
                    writeLog(String.Format("Error: {0}\n", ex.Message));
                    imgResult = null;
                }
                writeLog(String.Format("Camera example complete...\n"));
            }

            // Clear camera list before releasing system
            camList.Clear();

            // Release system
            system.Dispose();

            writeLog(String.Format("Done!\n"));

            return(imgResult);
        }