public void SetBlanking() { System.Diagnostics.Debug.Assert(m_pHandle != IntPtr.Zero); HVSTATUS status = USBCameraAPI.HVSetBlanking(m_pHandle, m_kHBlanking, m_kVBlanking); USBCameraAPI.HV_VERIFY(status); }
public void SetSnapSpeed() { System.Diagnostics.Debug.Assert(m_pHandle != IntPtr.Zero); HVSTATUS status = USBCameraAPI.HVSetSnapSpeed(m_pHandle, m_kSnapSpeed); USBCameraAPI.HV_VERIFY(status); }
public void SetADC() { System.Diagnostics.Debug.Assert(m_pHandle != IntPtr.Zero); HVSTATUS status = USBCameraAPI.HVADCControl(m_pHandle, (byte)HV_ADC_CONTROL.ADC_BITS, m_kADCLevel); USBCameraAPI.HV_VERIFY(status); }
public void SetResolution() { System.Diagnostics.Debug.Assert(m_pHandle != IntPtr.Zero); HVSTATUS status = USBCameraAPI.HVSetResolution(m_pHandle, m_kResolotion); USBCameraAPI.HV_VERIFY(status); }
public void BeginDevice() { if (m_pHandle == IntPtr.Zero) { HVSTATUS status = USBCameraAPI.BeginHVDevice(m_kCameraNums, ref m_pHandle); USBCameraAPI.HV_VERIFY(status); } }
public void EndDevice() { if (m_pHandle != IntPtr.Zero) { HVSTATUS status = USBCameraAPI.EndHVDevice(m_pHandle); USBCameraAPI.HV_VERIFY(status); } }
public void SetExposureTime(int exposureTime) { System.Diagnostics.Debug.Assert(m_pHandle != IntPtr.Zero); HVSTATUS status = SetExposureTime(m_OutPutWindow.Width, exposureTime, m_kLowerET, m_kHBlanking, m_kSnapSpeed, m_kResolotion); USBCameraAPI.HV_VERIFY(status); }
private void OpenSnap() { System.Diagnostics.Debug.Assert(m_Camera.GetHandle() != IntPtr.Zero); HVSTATUS status = USBCameraAPI.HVOpenSnap(m_Camera.GetHandle(), snapCallback, this.Handle); USBCameraAPI.HV_VERIFY(status); if (USBCameraAPI.HV_SUCCESS(status)) { m_bIsOpen = true; } }
public void SetGain(int gainValue) { System.Diagnostics.Debug.Assert(m_pHandle != IntPtr.Zero); m_kGain = gainValue; HVSTATUS status = HVSTATUS.STATUS_OK; for (int i = 0; i < 4; i++) { status = USBCameraAPI.HVAGCControl(m_pHandle, (byte)(HV_CHANNEL.RED_CHANNEL + i), m_kGain); USBCameraAPI.HV_VERIFY(status); } }
private void CloseSnap() { System.Diagnostics.Debug.Assert(m_Camera.GetHandle() != IntPtr.Zero); StopSnap(); HVSTATUS status = USBCameraAPI.HVCloseSnap(m_Camera.GetHandle()); USBCameraAPI.HV_VERIFY(status); if (USBCameraAPI.HV_SUCCESS(status)) { m_bIsOpen = false; } }
private void StartSnap() { System.Diagnostics.Debug.Assert(m_Camera.GetHandle() != IntPtr.Zero); IntPtr[] pBuffers = new IntPtr[1]; pBuffers[0] = m_Camera.GetRawBuffer(); HVSTATUS status = USBCameraAPI.HVStartSnap(m_Camera.GetHandle(), pBuffers, 1); USBCameraAPI.HV_VERIFY(status); if (USBCameraAPI.HV_SUCCESS(status)) { m_bIsSnap = true; } }
public void SetOutPutWindow() { System.Diagnostics.Debug.Assert(m_pHandle != IntPtr.Zero); IntPtr buffer = new IntPtr(); int size = 0; HVSTATUS status = USBCameraAPI.HVGetDeviceInfo(m_pHandle, HV_DEVICE_INFO.DESC_RESOLUTION, buffer, ref size); buffer = Marshal.AllocHGlobal(size); status = USBCameraAPI.HVGetDeviceInfo(m_pHandle, HV_DEVICE_INFO.DESC_RESOLUTION, buffer, ref size); USBCameraAPI.HV_VERIFY(status); int[] type = new int[64]; Marshal.Copy(buffer, type, 0, 64); Marshal.FreeHGlobal(buffer); m_OutPutWindow.Width = type[(int)m_kResolotion * 2]; m_OutPutWindow.Height = type[(int)m_kResolotion * 2 + 1]; status = USBCameraAPI.HVSetOutputWindow(m_pHandle, m_OutPutWindow.X, m_OutPutWindow.Y, m_OutPutWindow.Width, m_OutPutWindow.Height); USBCameraAPI.HV_VERIFY(status); }
public void GetCameraType() { System.Diagnostics.Debug.Assert(m_pHandle != IntPtr.Zero); IntPtr buffer = new IntPtr(); int size = sizeof(HVTYPE); StringBuilder str = new StringBuilder(); buffer = Marshal.AllocHGlobal(size); HVSTATUS status = USBCameraAPI.HVGetDeviceInfo(m_pHandle, HV_DEVICE_INFO.DESC_DEVICE_TYPE, buffer, ref size); USBCameraAPI.HV_VERIFY(status); int[] type = new int[size / 4]; Marshal.Copy(buffer, type, 0, size / 4); for (int i = 0; i < size / 4; i++) { str.Append(((HVTYPE)type[i]).ToString().Substring(0, 8)); } m_strCameraType = str.ToString(); str.Remove(0, str.Length); Marshal.FreeHGlobal(buffer); }
protected HVSTATUS SetExposureTime(int nWindWidth, int nUpper, int nLower, int nHBlanking, HV_SNAP_SPEED SnapSpeed, HV_RESOLUTION Resolution) { double clockFreq = 0.0; int tB = nHBlanking; int outPut = nWindWidth; double exposure = 0.0; Debug.Assert(nLower != 0); double temp = (double)nUpper / (double)nLower; double tInt = (temp > m_kZeorInDouble) ? temp : m_kZeorInDouble; if (IsGV400()) { tB += 0x5e; clockFreq = (SnapSpeed == HV_SNAP_SPEED.HIGH_SPEED) ? 26600000.0 : 13300000.0; int rate = 0; switch (Resolution) { case HV_RESOLUTION.RES_MODE0: rate = 1; break; case HV_RESOLUTION.RES_MODE1: rate = 2; break; default: return(HVSTATUS.STATUS_PARAMETER_OUT_OF_BOUND); } outPut = outPut * rate; if ((tInt * clockFreq) <= (outPut + tB - 255)) { exposure = 1; } else { Debug.Assert((outPut + tB) != 0); exposure = ((tInt * clockFreq) - (outPut + tB - 255)) / (outPut + tB); } if (exposure < 3) { exposure = 3; } else if (exposure > 32766) { exposure = 32766; } } else if (IsHV300()) { clockFreq = (SnapSpeed == HV_SNAP_SPEED.HIGH_SPEED) ? 24000000 : 12000000; tB += 142; if (tB < 21) { tB = 21; } int param1 = 331; int param2 = 38; int param3 = 316; if (Resolution == HV_RESOLUTION.RES_MODE1) { param1 = 673; param2 = 22; param3 = 316 * 2; } int AQ = outPut + param1 + param2 + tB; int tmp = param1 + param3; int trow = (AQ > tmp) ? AQ : tmp; Debug.Assert(trow != 0); exposure = ((tInt * clockFreq) + param1 - 132.0) / trow; if ((exposure - (int)exposure) > 0.5) { exposure += 1.0; } if (exposure <= 0) { exposure = 1; } else if (exposure > 1048575) { exposure = 1048575; } } else if (IsHV200()) { clockFreq = (SnapSpeed == HV_SNAP_SPEED.HIGH_SPEED) ? 24000000 : 12000000; tB += 53; if (tB < 19) { tB = 19; } int AQ = outPut + 305 + tB; int trow = (617 > AQ) ? 617 : AQ; Debug.Assert((trow + 1) != 0); exposure = (tInt * clockFreq + 180.0) / trow + 1; if ((exposure - (int)exposure) > 0.5) { exposure += 1.0; } if (exposure <= 0) { exposure = 1; } else if (exposure > 16383) { exposure = 16383; } } else if (IsHV5051()) { SHUTTER_UNIT_VALUE unit = SHUTTER_UNIT_VALUE.SHUTTER_MS; if (nLower == 1000000) { unit = SHUTTER_UNIT_VALUE.SHUTTER_US; } //设置曝光时间单位 HVSTATUS status = USBCameraAPI.HVAECControl(m_pHandle, (byte)HV_AEC_CONTROL.AEC_SHUTTER_UNIT, (int)unit); if (!USBCameraAPI.HV_SUCCESS(status)) { return(status); } //设置曝光时间 return(USBCameraAPI.HVAECControl(m_pHandle, (byte)HV_AEC_CONTROL.AEC_SHUTTER_SPEED, nUpper)); } else { clockFreq = (SnapSpeed == HV_SNAP_SPEED.HIGH_SPEED) ? 24000000 : 12000000; tB += 9; tB -= 19; if (tB <= 0) { tB = 0; } if ((outPut + 244.0 + tB) > 552) { exposure = (tInt * clockFreq + 180.0) / ((double)outPut + 244.0 + tB); } else { exposure = ((tInt * clockFreq) + 180.0) / 552; } if ((exposure - (int)exposure) > 0.5) { exposure += 1.0; } if (exposure <= 0) { exposure = 1; } else if (exposure > 16383) { exposure = 16383; } } return(USBCameraAPI.HVAECControl(m_pHandle, (byte)HV_AEC_CONTROL.AEC_EXPOSURE_TIME, (int)exposure)); }