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); }
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(); } }
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); }
private void DestroyObjects() { if (m_Xfer != null && m_Xfer.Initialized) { m_Xfer.Destroy(); } if (m_Buffers != null && m_Buffers.Initialized) { m_Buffers.Destroy(); } if (m_Acquisition != null && m_Acquisition.Initialized) { m_Acquisition.Destroy(); } }
/// <summary> /// 销毁 采集、传输、缓存对象 /// </summary> public void SeparaInterface_DestroyObjects() { if (m_Xfer != null && m_Xfer.Initialized) { m_Xfer.Destroy(); } if (m_Buffers != null && m_Buffers.Initialized) { m_Buffers.Destroy(); } if (m_Acquisition != null && m_Acquisition.Initialized) { m_Acquisition.Destroy(); } }
private void DestroyObjects() { if (m_Xfer != null && m_Xfer.Initialized) { m_Xfer.Destroy(); } if (m_Buffers != null && m_Buffers.Initialized) { m_Buffers.Destroy(); } if (m_AcqDevice != null && m_AcqDevice.Initialized) { m_AcqDevice.Destroy(); } }
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); } }
// // 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(); }