public static void DaHeng_Uninit() { try { if (m_objIGXFactory == null) { return; } m_objIGXFactory.Uninit(); m_objIGXFactory = null; return; } catch (Exception ex) { m_objIGXFactory = null; return; } }
public void Uninit() { m_objIGXFactory.Uninit(); }
/// 拍摄单张 public void SingleShot(string save_path) { strSingleShotName = save_path; try { m_objIGXFactory = IGXFactory.GetInstance(); m_objIGXFactory.Init(); List <IGXDeviceInfo> listGXDeviceInfo = new List <IGXDeviceInfo>(); //关闭流 __CloseStream(); // 如果设备已经打开则关闭,保证相机在初始化出错情况下能再次打开 __CloseDevice(); m_objIGXFactory.UpdateDeviceList(200, listGXDeviceInfo); // 判断当前连接设备个数 if (listGXDeviceInfo.Count <= 0) { MessageBox.Show("未发现设备!"); return; } str_MySN = listGXDeviceInfo[0].GetSN(); m_objIGXDevice = m_objIGXFactory.OpenDeviceBySN(str_MySN, GX_ACCESS_MODE.GX_ACCESS_EXCLUSIVE); if (null == m_objIGXDevice) { MessageBox.Show(string.Format("未能打开相机{0}设备。", str_MySN)); return; } m_objGxBitmap = new GxBitmap(m_objIGXDevice); m_objIGXFeatureControl = m_objIGXDevice.GetRemoteFeatureControl(); if (null == m_objIGXFeatureControl) { MessageBox.Show(string.Format("未获得相机{0}属性控制。", str_MySN)); return; } m_objIGXStream = m_objIGXDevice.OpenStream(0); if (null == m_objIGXStream) { MessageBox.Show(string.Format("相机{0}获取流失败。", str_MySN)); } //初始化相机参数 m_objIGXFeatureControl.GetEnumFeature("AcquisitionMode").SetValue("Continuous"); m_objIGXFeatureControl.GetEnumFeature("TriggerMode").SetValue("Off"); //打开流,获得单帧图像 m_objIGXStream.StartGrab(); m_objIGXFeatureControl.GetCommandFeature("AcquisitionStart").Execute(); IImageData singleImageData = m_objIGXStream.GetImage(100); m_objIGXFeatureControl.GetCommandFeature("AcquisitionStop").Execute(); m_objIGXFeatureControl = null; m_objIGXStream.StopGrab(); __CloseStream(); __CloseDevice(); m_objIGXFactory.Uninit(); if (!Directory.Exists(m_strFilePath)) { Directory.CreateDirectory(m_strFilePath); } strSingleShotName = m_strFilePath + "\\" + strSingleShotName; m_objGxBitmap.SaveBmp(singleImageData, strSingleShotName); return; } catch (Exception ex) { MessageBox.Show(ex.Message); } }