コード例 #1
0
        /// <summary>
        /// Handles the FrameReceived event
        /// </summary>
        /// <param name="sender">The Sender</param>
        /// <param name="args">The FrameEventArgs</param>
        private void OnFrameReceived(object sender, FrameEventArgs args)
        {
            // Start an async invoke in case this method was not
            // called by the GUI thread.
            if (InvokeRequired == true)
            {
                BeginInvoke(new FrameReceivedHandler(this.OnFrameReceived), sender, args);
                return;
            }

            if (true == m_Acquiring)
            {
                Mat img = BitmapConverter.ToMat(new Bitmap(args.Image));
                img = img.CvtColor(ColorConversionCodes.RGB2GRAY);
                Mat colorMapImg = new Mat();
                //Cv2.ApplyColorMap(img, colorMapImg, ColormapTypes.Jet);
                Cv2.ApplyColorMap(img, colorMapImg, ColormapTypes.Jet);
                //Cv2.ImShow("Jet", colorMapImg);

                // Display image
                //Image image = args.Image;
                Image image = BitmapConverter.ToBitmap(colorMapImg);
                if (null != image)
                {
                    m_PictureBox.Image = image;
                }
                else
                {
                    LogMessage("An acquisition error occurred. Reason: " + args.Exception.Message);

                    try
                    {
                        try
                        {
                            // Start asynchronous image acquisition (grab) in selected camera
                            m_VimbaHelper.StopContinuousImageAcquisition();
                        }
                        finally
                        {
                            m_Acquiring = false;
                            UpdateControls();
                            m_CameraList.Enabled = true;
                        }

                        LogMessage("Asynchronous image acquisition stopped.");
                    }
                    catch (Exception exception)
                    {
                        LogError("Error while stopping asynchronous image acquisition. Reason: " + exception.Message);
                    }
                }
            }
        }
コード例 #2
0
ファイル: frmMonitorCam.cs プロジェクト: se0min/DiaDetector
        /// <summary>
        /// Handles the FrameReceived event
        /// </summary>
        /// <param name="sender">The Sender</param>
        /// <param name="args">The FrameEventArgs</param>
        private void OnFrameReceived(object sender, FrameEventArgs args)
        {
            // Start an async invoke in case this method was not
            // called by the GUI thread.
            if (InvokeRequired == true)
            {
                BeginInvoke(new FrameReceivedHandler(this.OnFrameReceived), sender, args);
                return;
            }

            if (true == m_Acquiring)
            {
                // Display image
                Image image = args.Image;
                if (null != image)
                {
                    m_PictureBox.Image = image;
                    //textBox1.Text += "\n" + "Capture Image!";
                }
                else
                {
                    //textBox1.Text += "\n" + "An acquisition error occurred. Reason: " + args.Exception.Message;

                    try
                    {
                        try
                        {
                            // Start asynchronous image acquisition (grab) in selected camera
                            m_VimbaHelper.StopContinuousImageAcquisition();
                        }
                        finally
                        {
                            m_Acquiring = false;
                            UpdateControls();
                            m_CameraList.Enabled = true;
                        }

                        textBox1.Text += "\n" + "Asynchronous image acquisition stopped.";
                    }
                    catch (Exception exception)
                    {
                        textBox1.Text += "\n" + "Error while stopping asynchronous image acquisition. Reason: " + exception.Message;
                    }
                }
            }
        }