예제 #1
0
        static void DestroysObjects(SapAcquisition acq, SapAcqDevice camera, SapBuffer buf, SapTransfer xfer, SapView view)
        {
            if (xfer != null)
            {
                xfer.Destroy();
                xfer.Dispose();
            }

            if (camera != null)
            {
                camera.Destroy();
                camera.Dispose();
            }

            if (acq != null)
            {
                acq.Destroy();
                acq.Dispose();
            }

            if (buf != null)
            {
                buf.Destroy();
                buf.Dispose();
            }

            if (view != null)
            {
                view.Destroy();
                view.Dispose();
            }

            //Console.WriteLine("\nPress any key to terminate\n");
            //Console.ReadKey(true);
        }
예제 #2
0
        static void DestroysObjects(SapAcquisition acq, SapAcqDevice camera, SapBuffer buf, SapTransfer xfer, SapView view)
        {
            if (xfer != null)
            {
                xfer.Destroy();
                xfer.Dispose();
            }

            if (camera != null)
            {
                camera.Destroy();
                camera.Dispose();
            }

            if (acq != null)
            {
                acq.Destroy();
                acq.Dispose();
            }

            if (buf != null)
            {
                buf.Destroy();
                buf.Dispose();
            }

            if (view != null)
            {
                view.Destroy();
                view.Dispose();
            }

            //Console.WriteLine("\nPress any key to terminate\n");
            //Console.ReadKey(true);
        }
예제 #3
0
        static void DestroysObjects(SapAcqDevice acq, SapBuffer buf, SapTransfer xfer, SapView view)
        {
            if (xfer != null && xfer.Initialized)
            {
                xfer.Destroy();
                xfer.Dispose();
            }

            if (acq != null && acq.Initialized)
            {
                acq.Destroy();
                acq.Dispose();
            }

            if (buf != null && buf.Initialized)
            {
                buf.Destroy();
                buf.Dispose();
            }

            if (view != null && view.Initialized)
            {
                view.Destroy();
                view.Dispose();
            }
        }
예제 #4
0
        public string CAM_StopGrab()
        {
            m_grabImages = false;
            try
            {
                //m_camera.StopCapture();
                Xfer.Freeze();
                if (Xfer != null)
                {
                    Xfer.Destroy();
                    Xfer.Dispose();
                }

                if (AcqDevice != null)
                {
                    AcqDevice.Destroy();
                    AcqDevice.Dispose();
                }

                if (Buffers != null)
                {
                    Buffers.Destroy();
                    Buffers.Dispose();
                }

                loc.Dispose();
            }
            catch (FC2Exception ex)
            {
                //MessageBox.Show("Failed to stop camera: " + ex.Message);
                return(string.Empty);
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Camera is null");
            }

            return(string.Empty);
        }
예제 #5
0
 private void DisposeObjects()
 {
     if (m_Xfer != null)
     {
         m_Xfer.Dispose(); m_Xfer = null;
     }
     if (m_Buffers != null)
     {
         m_Buffers.Dispose(); m_Buffers = null;
     }
     if (m_AcqDevice != null)
     {
         m_AcqDevice.Dispose(); m_AcqDevice = null;
     }
 }
예제 #6
0
 private void DisposeObjects()
 {
     if (m_Xfer != null)
     {
         m_Xfer.Dispose(); m_Xfer = null;
     }
     if (m_Buffers != null)
     {
         m_Buffers.Dispose(); m_Buffers = null;
     }
     if (m_Acquisition != null)
     {
         m_Acquisition.Dispose(); m_Acquisition = null;
     }
 }
예제 #7
0
 /// <summary>
 /// 清空 采集、传输、缓存对象
 /// </summary>
 public void SeparaInterface_DisposeObjects()
 {
     if (m_Xfer != null)
     {
         m_Xfer.Dispose(); m_Xfer = null;
     }
     if (m_Buffers != null)
     {
         m_Buffers.Dispose(); m_Buffers = null;
     }
     if (m_Acquisition != null)
     {
         m_Acquisition.Dispose(); m_Acquisition = null;
     }
 }
예제 #8
0
        private void DisposeObjects()
        {
            if (m_Xfer != null)
            {
                m_Xfer.Dispose(); m_Xfer = null;
            }
//             if (m_View != null)
//             { m_View.Dispose(); m_View = null; m_ImageBox.View = null; }
            if (m_Buffers != null)
            {
                m_Buffers.Dispose(); m_Buffers = null;
            }
            if (m_Acquisition != null)
            {
                m_Acquisition.Dispose(); m_Acquisition = null;
            }
        }
예제 #9
0
        public override bool?Disconnect()
        {
            try
            {
                if (Xfer != null)
                {
                    Xfer.Destroy();
                    Xfer.Dispose();
                }

                if (AcqDevice != null)
                {
                    AcqDevice.Destroy();
                    AcqDevice.Dispose();
                }

                if (Acquisition != null)
                {
                    Acquisition.Destroy();
                    Acquisition.Dispose();
                }

                if (Buffers != null)
                {
                    Buffers.Destroy();
                    Buffers.Dispose();
                }

                if (View != null)
                {
                    View.Destroy();
                    View.Dispose();
                }
                if (ServerLocation != null)
                {
                    ServerLocation.Dispose();
                }
                return(true);
            }
            catch (Exception ex)
            {
                ex.ToString().Print("Disconnect Error");
                return(null);
            }
        }
예제 #10
0
 /// <summary>
 /// 释放句柄
 /// </summary>
 private void DisposeObjects()
 {
     if (m_Xfer != null)
     {
         m_Xfer.Dispose(); m_Xfer = null;
     }
     if (m_View != null)
     {
         m_View.Dispose(); m_View = null; m_ImageBox.View = null;
     }
     if (m_Buffers != null)
     {
         m_Buffers.Dispose(); m_Buffers = null;
     }
     if (m_AcqDevice != null)
     {
         m_AcqDevice.Dispose(); m_AcqDevice = null;
     }
 }
예제 #11
0
        //
        // Step 2: Snap a bright image to calculate the gain coefficients
        //
        private void button_Acq_Bright_Click(object sender, EventArgs e)
        {
            int nbImagesUsed = m_pFlatField.CorrectionType == SapFlatField.ScanCorrectionType.Field ? int.Parse(textBox_Frame_Avg.Text) : 1;

            // Set maximum deviation from average pixel value for bright image
            m_pFlatField.DeviationMaxWhite = int.Parse(textBox_Max_Dev.Text);

            // Set number of lines to average and vertical offset
            m_pFlatField.NumLinesAverage = int.Parse(textBox_Line_Avg.Text);
            m_pFlatField.VerticalOffset  = int.Parse(textBox_Vert_Offset.Text);

            // Set wether to declare pixels with clipped coefficient as defective
            m_pFlatField.ClippedGainOffsetDefects = ClippedCoefsDefects_checkbox.Checked;

            if (m_pXfer != null && m_pXfer.Initialized)
            {
                m_pLocalBuffer = new SapBuffer(nbImagesUsed, m_pBuffer, SapBuffer.MemoryType.Default);
                m_pLocalBuffer.Create();

                // Acquire an image
                if (!Snap())
                {
                    LogMessage(LogTypes.Error, "Unable to acquire an image");
                    if (m_pLocalBuffer != null)
                    {
                        m_pLocalBuffer.Destroy();
                        m_pLocalBuffer.Dispose();
                        m_pLocalBuffer = null;
                    }
                    return;
                }
            }
            else
            {
                // Load an image
                m_pLocalBuffer = new SapBuffer(1, m_pBuffer, SapBuffer.MemoryType.Default);
                m_pLocalBuffer.Create();


                LoadSaveDlg dlg = new LoadSaveDlg(null, true, false);
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    if (m_pLocalBuffer != null)
                    {
                        m_pLocalBuffer.Destroy();
                        m_pLocalBuffer.Dispose();
                        m_pLocalBuffer = null;
                    }
                    return;
                }

                String path = dlg.PathName;

                // Create a temporary buffer in order to know the selected file's native format and pixel depth

                SapBuffer loadBuffer = new SapBuffer(path, SapBuffer.MemoryType.Default);
                loadBuffer.Create();

                if (loadBuffer.Format != m_pBuffer.Format || loadBuffer.PixelDepth != m_pBuffer.PixelDepth)
                {
                    LogMessage(LogTypes.Warning, "Image file has a different format than expected.  Pixel values may get shifted.");
                }

                if (loadBuffer.Width != m_pBuffer.Width || loadBuffer.Height != m_pBuffer.Height)
                {
                    LogMessage(LogTypes.Error, "Image file selected doesn't have same dimensions as buffer.");
                    if (m_pLocalBuffer != null)
                    {
                        m_pLocalBuffer.Destroy();
                        m_pLocalBuffer.Dispose();
                        m_pLocalBuffer = null;
                    }
                    return;
                }

                loadBuffer.Load(path, 1);
                m_pLocalBuffer.Copy(loadBuffer);

                String str;
                str = String.Format("Loaded bright image: '{0}'", path);
                LogMessage(LogTypes.Info, str);
            }

            BrightImage();
        }