Beispiel #1
0
        private void Initialize(string name)
        {
            var errorCode = Acquisition_GbIF_Init(out m_AcqDesc, 0, true, 0, 0, true, false, HIS_GbIF_NAME, name);

            CheckError(errorCode);
            errorCode = Acquisition_GbIF_GetDevice(name, HIS_GbIF_NAME, out GBIF_DEVICE_PARAM deviceParam);
            CheckError(errorCode);
            Info = deviceParam.ToInfo();

            m_EndFrameCallback = EndFrameCallback;
            m_EndAcqCallback   = EndAcqCallback;
            errorCode          = Acquisition_SetCallbacksAndMessages(m_AcqDesc, IntPtr.Zero, 0, 0, Marshal.GetFunctionPointerForDelegate(m_EndFrameCallback),
                                                                     Marshal.GetFunctionPointerForDelegate(m_EndAcqCallback));
            CheckError(errorCode);

            errorCode = Acquisition_SetIdleTimeout(m_AcqDesc, ushort.MaxValue);
            errorCode = Acquisition_SetCameraTriggerMode(m_AcqDesc, 3);
            CheckError(errorCode);

            var info   = new uint[24];
            var infoEx = new ushort[32];

            errorCode = Acquisition_GetHwHeaderInfoEx(m_AcqDesc, info, infoEx);
            CheckError(errorCode);
            m_ImageWidth  = infoEx[5];
            m_ImageHeight = infoEx[4];
            m_ImagePitch  = infoEx[2];
            m_ImageData   = new UnmanagedBuffer(m_ImageWidth * m_ImageHeight * 2);
        }
Beispiel #2
0
 public void ClearPixelMap()
 {
     if (m_PixelMap != null)
     {
         m_PixelMap.Dispose();
         m_PixelMap = null;
     }
 }
Beispiel #3
0
 public void ClearOffsetMap()
 {
     if (m_OffsetMap != null)
     {
         m_OffsetMap.Dispose();
         m_OffsetMap = null;
     }
 }
Beispiel #4
0
 public void ClearGainMap()
 {
     if (m_GainMap != null)
     {
         m_GainMap.Dispose();
         m_GainMap = null;
     }
 }
Beispiel #5
0
        public async Task StartGainCalibration(int frameCount)
        {
            ClearGainMap();
            m_GainMap = new UnmanagedBuffer(m_ImageWidth * m_ImageHeight * 4);

            var errorCode = Acquisition_Acquire_GainImage(m_AcqDesc, m_OffsetMap, m_GainMap, m_ImageHeight, m_ImageWidth, frameCount);

            CheckError(errorCode);
            await LoopFramesAsync(frameCount);
        }
Beispiel #6
0
        public static UnmanagedBuffer Load(string filePath, int headerSize = 0)
        {
            var buffer = new UnmanagedBuffer((int)new FileInfo(filePath).Length - headerSize);

            using (Stream fileStream = File.OpenRead(filePath), bufferStream = buffer.CreateStream(FileAccess.Write))
            {
                fileStream.Position += headerSize;
                fileStream.CopyTo(bufferStream);
            }
            return(buffer);
        }
Beispiel #7
0
        public void Dispose()
        {
            if (m_AcqDesc != IntPtr.Zero)
            {
                var errorCode = Acquisition_Close(m_AcqDesc);
                CheckError(errorCode);
                m_AcqDesc = IntPtr.Zero;
            }

            if (m_ImageData != null)
            {
                m_ImageData.Dispose();
                m_ImageData = null;
            }

            ClearOffsetMap();
            ClearGainMap();
            ClearPixelMap();
        }
Beispiel #8
0
        public DetectorBatteryStatus GetBatteryStatus(out int batteryGauge)
        {
            using (var cameraRegisters = new UnmanagedBuffer(500))
            {
                var errorCode = Acquisition_wpe_ReadCameraRegisters(Info.IP, cameraRegisters);
                CheckError(errorCode);

                batteryGauge = 0;
                var batteryInfo = (DETECTOR_BATTERY)Marshal.PtrToStructure((IntPtr)cameraRegisters + 31 * 4, typeof(DETECTOR_BATTERY));
                if (batteryInfo.SerialNo != 0)
                {
                    if ((batteryInfo.Status & 0x01) != 0)
                    {
                        batteryGauge = batteryInfo.Capacity;
                        return((batteryInfo.Status & 0x02) != 0 ? DetectorBatteryStatus.Charging : DetectorBatteryStatus.Discharging);
                    }
                    else
                    {
                        return(DetectorBatteryStatus.NotInstalled);
                    }
                }
                return(DetectorBatteryStatus.Disconnected);
            }
        }
Beispiel #9
0
 public void LoadPixelMap(string filePath)
 {
     ClearPixelMap();
     m_PixelMap = UnmanagedBuffer.Load(filePath, 100);
 }
Beispiel #10
0
 public void LoadGainMap(string filePath)
 {
     ClearGainMap();
     m_GainMap = UnmanagedBuffer.Load(filePath);
 }
Beispiel #11
0
 public void LoadOffsetMap(string filePath)
 {
     ClearOffsetMap();
     m_OffsetMap = UnmanagedBuffer.Load(filePath);
 }