unsafe private void Button_CAPTURE_Click(object sender, EventArgs e) { if (m_nDeviceCurSel == -1) { return; } int nCaptureWidth = 0; int nCaptureHeight = 0; int nCaptureBitCount = 0; KSJApiTriggerMode.KSJ_TriggerModeSet(m_nDeviceCurSel, KSJApiTriggerMode.KSJ_TRIGGERMODE.KSJ_TRIGGER_SOFTWARE); int nRet = KSJApiBase.KSJ_CaptureGetSizeEx(m_nDeviceCurSel, ref nCaptureWidth, ref nCaptureHeight, ref nCaptureBitCount); PrintErrorMessage(nRet); byte[] pImageData = new byte[nCaptureWidth * nCaptureHeight * (nCaptureBitCount >> 3)]; long counterStart = 0; KSJWin.QueryPerformanceCounter(ref counterStart); nRet = KSJApiBase.KSJ_CaptureRgbData(m_nDeviceCurSel, pImageData); PrintErrorMessage(nRet); if (nRet != KSJCode.RET_SUCCESS) { TextBox_ELAPSE_TIME.Text = "Capture Fail."; } long counterEnd = 0; KSJWin.QueryPerformanceCounter(ref counterEnd); long nFreq = 0; KSJWin.QueryPerformanceFrequency(ref nFreq); float fInterval = (float)(counterEnd - counterStart); float fElapse = fInterval / (float)nFreq * 1000; // MS bool bCheck = CheckBox_SAVE.Checked; if (bCheck) { string szFileName = string.Format("capture-{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}.bmp", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond, fElapse); KSJApiBase.KSJ_HelperSaveToBmp(pImageData, nCaptureWidth, nCaptureHeight, nCaptureBitCount, szFileName); } TextBox_ELAPSE_TIME.Text = string.Format("Elapse: {0}ms", fElapse); Bitmap bitmap = BytesToBitmap(pImageData, nCaptureWidth, nCaptureHeight, nCaptureBitCount); PictureBox_PREVIEWWND.Image = bitmap; }
private void UpdateTrigger()//更新触发模式 { string[] szMode = new string[4] { "Internal", "External", "Software", "Fixed Frame Rate" }; int nMin = 0; int nMax = 0; KSJApiBase.KSJ_GetParamRange(m_nDeviceCurSel, KSJApiBase.KSJ_PARAM.KSJRIGGER_MODE, ref nMin, ref nMax); int i = 0; for (i = 0; i < 4; i++) { comboBox_TriggerMode.Items.Insert(i, szMode[i]); } if (nMax == 4) { comboBox_TriggerMode.Items.Insert(i, "High Low Fixed Frame Rate"); } KSJApiTriggerMode.KSJ_TriggerModeGet(m_nDeviceCurSel, ref m_TriggerMode); comboBox_TriggerMode.SelectedIndex = (int)m_TriggerMode; string[] szMethod = new string[4] { "Falling Edge", "Rising Edge", "High Level", "Low Level" }; for (i = 0; i < 4; i++) { comboBox_TriggerMethod.Items.Insert(i, szMethod[i]); } KSJApiTriggerMode.KSJ_TriggerMethodGet(m_nDeviceCurSel, ref m_TriggerMethod); comboBox_TriggerMethod.SelectedIndex = (int)m_TriggerMethod; KSJApiTriggerMode.KSJ_GetFixedFrameRateEx(m_nDeviceCurSel, ref m_fFixedFrameRate); FrameRate.Value = (decimal)m_fFixedFrameRate; }
private void FrameRate_ValueChanged(object sender, EventArgs e) { m_fFixedFrameRate = (float)FrameRate.Value; KSJApiTriggerMode.KSJ_SetFixedFrameRateEx(m_nDeviceCurSel, m_fFixedFrameRate); }
private void comboBox_TriggerMethod_SelectedIndexChanged(object sender, EventArgs e) { m_TriggerMethod = (KSJApiTriggerMode.KSJ_TRIGGERMETHOD)comboBox_TriggerMethod.SelectedIndex; KSJApiTriggerMode.KSJ_TriggerMethodSet(m_nDeviceCurSel, m_TriggerMethod); }
private void comboBox_TriggerMode_SelectedIndexChanged(object sender, EventArgs e) { m_TriggerMode = (KSJApiTriggerMode.KSJ_TRIGGERMODE)comboBox_TriggerMode.SelectedIndex; KSJApiTriggerMode.KSJ_TriggerModeSet(m_nDeviceCurSel, m_TriggerMode); }