Example #1
0
        /// <summary>
        /// Starts the continuous image acquisition and opens the camera
        /// Registers the event handler for the new frame event
        /// </summary>
        /// <param name="id">The camera ID</param>
        /// <param name="showCameraInfo">Flag to indicate if the Camera info data shall be shown or not</param>
        public void StartContinuousImageAcquisition(string id, FrameInfos showCameraInfo)
        {
            // Check parameters
            if (null == id)
            {
                throw new ArgumentNullException("id");
            }

            // Check if API has been started up at all
            if (null == m_Vimba)
            {
                throw new Exception("Vimba is not started.");
            }

            // Check if a camera is already open
            if (null != m_Camera)
            {
                throw new Exception("A camera is already open.");
            }

            // show camera info's in the console Output :
            m_ShowFrameInfo = showCameraInfo;

            // Open camera
            m_Camera = m_Vimba.OpenCameraByID(id, VmbAccessModeType.VmbAccessModeFull);
            if (null == m_Camera)
            {
                throw new NullReferenceException("No camera retrieved.");
            }

            // Set the GeV packet size to the highest possible value
            // (In this example we do not test whether this cam actually is a GigE cam)
            try
            {
                m_Camera.Features["GVSPAdjustPacketSize"].RunCommand();
                while (false == m_Camera.Features["GVSPAdjustPacketSize"].IsCommandDone())
                {
                    // Do nothing
                }
            }

            catch
            {
                // Do nothing
            }

            bool error = true;

            try
            {
                // Register frame callback
                m_Camera.OnFrameReceived += this.OnFrameReceived;

                // Reset member variables
                m_Acquiring = true;

                // Start synchronous image acquisition (grab)
                m_Camera.StartContinuousImageAcquisition(3);

                error = false;
            }
            finally
            {
                // Close camera already if there was an error
                if (true == error)
                {
                    ReleaseCamera();
                }
            }
        }
Example #2
0
        public void OpenCamera(string id, FrameInfos showCameraInfo)
        {
            // Check parameters
            if (null == id)
            {
                throw new ArgumentNullException("id");
            }

            // Check if API has been started up at all
            if (null == m_Vimba)
            {
                throw new Exception("Vimba is not started.");
            }

            // Check if a camera is already open
            if (null != m_Camera)
            {
                throw new Exception("A camera is already open.");
            }

            // show camera info's in the console Output :
            m_ShowFrameInfo = showCameraInfo;

            // Open camera
            m_Camera = m_Vimba.OpenCameraByID(id, VmbAccessModeType.VmbAccessModeFull);
            if (null == m_Camera)
            {
                throw new NullReferenceException("No camera retrieved.");
            }

            // Set the GeV packet size to the highest possible value
            // (In this example we do not test whether this cam actually is a GigE cam)
            try
            {
                /*
                 * m_Camera.Features["GVSPAdjustPacketSize"].RunCommand();
                 * while (false == m_Camera.Features["GVSPAdjustPacketSize"].IsCommandDone())
                 * {
                 *  // Do nothing
                 * }
                 */

                // Joe: set multiframe 16 photos mode
                m_Camera.Features["AcquisitionMode"].EnumValue      = "MultiFrame";
                m_Camera.Features["AcquisitionFrameCount"].IntValue = 16;

                m_Camera.Features["DeviceLinkThroughputLimit"].IntValue = 440000000;

                m_Camera.Features["Width"].IntValue  = 1200;
                m_Camera.Features["Height"].IntValue = 800;

                m_Camera.Features["OffsetX"].IntValue = (m_Camera.Features["WidthMax"].IntValue - m_Camera.Features["Width"].IntValue) / 2 / 4 * 4;
                m_Camera.Features["OffsetY"].IntValue = (m_Camera.Features["HeightMax"].IntValue - m_Camera.Features["Height"].IntValue) / 2 / 4 * 4;
            }
            catch
            {
                // Do nothing
                Console.WriteLine("Failed to set parameters for the camera !");
            }

            bool error = true;

            try
            {
                // Register frame callback
                m_Camera.OnFrameReceived += this.OnFrameReceived;

                // Reset member variables
                //m_Acquiring = true;
                m_Acquiring = false;

                // Start synchronous image acquisition (grab)
                //m_Camera.StartContinuousImageAcquisition(3);

                error = false;
            }
            finally
            {
                // Close camera already if there was an error
                if (true == error)
                {
                    ReleaseCamera();
                }
            }
        }
Example #3
0
        /// <summary>
        /// Starts the continuous image acquisition and opens the camera
        /// Registers the event handler for the new frame event
        /// </summary>
        /// <param name="id">The camera ID</param>
        /// <param name="showCameraInfo">Flag to indicate if the Camera info data shall be shown or not</param>
        public void StartContinuousImageAcquisition(string id, FrameInfos showCameraInfo)
        {
            // Check parameters
            if (null == id)
            {
                throw new ArgumentNullException("id");
            }

            // Check if API has been started up at all
            if (null == m_Vimba)
            {
                throw new Exception("Vimba is not started.");
            }

            // Check if a camera is already open
            if (null != m_Camera)
            {
                throw new Exception("A camera is already open.");
            }

            // show camera info's in the console Output :
            m_ShowFrameInfo = showCameraInfo;

            // Open camera
            m_Camera = m_Vimba.OpenCameraByID(id, VmbAccessModeType.VmbAccessModeFull);
            if (null == m_Camera)
            {
                throw new NullReferenceException("No camera retrieved.");
            }

            // Set the GeV packet size to the highest possible value
            // (In this example we do not test whether this cam actually is a GigE cam)
            try
            {
                m_Camera.Features["GVSPAdjustPacketSize"].RunCommand();
                while (false == m_Camera.Features["GVSPAdjustPacketSize"].IsCommandDone())
                {
                }
            }
            catch
            {
                // Do nothing
            }

            bool error = true;

            try
            {
                Console.WriteLine("\nConfiguring Camera Parameters...");
                //Console.Write("Available Triggers: ");
                //Console.WriteLine(string.Join(", ", m_Camera.Features["TriggerSource"].EnumValues));

                m_Camera.Features["ExposureMode"].EnumValue      = "TriggerWidth";
                m_Camera.Features["TriggerSelector"].EnumValue   = "FrameStart";
                m_Camera.Features["TriggerSource"].EnumValue     = "Line1";
                m_Camera.Features["TriggerActivation"].EnumValue = "RisingEdge";
                m_Camera.Features["TriggerMode"].EnumValue       = "On";
                m_Camera.Features["Gain"].FloatValue             = m_GainValue;

                Console.WriteLine("ExposureMode: " + m_Camera.Features["ExposureMode"].EnumValue);
                Console.WriteLine("TriggerSelector: " + m_Camera.Features["TriggerSelector"].EnumValue);
                Console.WriteLine("TriggerSource: " + m_Camera.Features["TriggerSource"].EnumValue);
                Console.WriteLine("TriggerActivation: " + m_Camera.Features["TriggerActivation"].EnumValue);
                Console.WriteLine("TriggerMode: " + m_Camera.Features["TriggerMode"].EnumValue);
                Console.WriteLine("Gain: " + m_Camera.Features["Gain"].FloatValue);
                Console.WriteLine("Saving to: " + m_Path);

                Console.WriteLine("\nReady for imaging!\n");

                // Register frame callback
                m_Camera.OnFrameReceived += this.OnFrameReceived;

                // Reset member variables
                m_Acquiring = true;

                // Start synchronous image acquisition (grab)
                m_Camera.StartContinuousImageAcquisition(m_shotSize);

                error = false;
            }
            finally
            {
                // Close camera already if there was an error
                if (true == error)
                {
                    ReleaseCamera();
                }
            }
        }