private void setRoi(TUCAM_ROI_ATTR roiAttr) { WaitForFrameThread.Abort(); TUCamera.TUCAM_Buf_AbortWait(mainform.m_opCamList[mainform.m_nCamIndex].hIdxTUCam); // If you called TUCAM_Buf_WaitForFrames() TUCamera.TUCAM_Cap_Stop(mainform.m_opCamList[mainform.m_nCamIndex].hIdxTUCam); // Stop capture TUCamera.TUCAM_Buf_Release(mainform.m_opCamList[mainform.m_nCamIndex].hIdxTUCam); // Release alloc buffer after stop capture and quit drawing thread TUCamera.TUCAM_Cap_SetROI(mainform.m_opCamList[mainform.m_nCamIndex].hIdxTUCam, roiAttr); TUCamera.TUCAM_Cap_GetROI(/*m_opCam.hIdxTUCam*/ mainform.m_opCamList[mainform.m_nCamIndex].hIdxTUCam, ref roiAttr); mainform.m_drawframe.pBuffer = IntPtr.Zero; mainform.m_drawframe.ucFormatGet = (byte)TUFRM_FORMATS.TUFRM_FMT_RGB888; mainform.m_drawframe.uiRsdSize = 1U; TUCamera.TUCAM_Buf_Alloc(mainform.m_opCamList[mainform.m_nCamIndex].hIdxTUCam, ref mainform.m_drawframe); // Alloc buffer after set resolution or set ROI attribute TUCamera.TUCAM_Cap_Start(mainform.m_opCamList[mainform.m_nCamIndex].hIdxTUCam, 0U); WaitForFrameThread = new System.Threading.Thread(new ThreadStart(WaitForFrame)); WaitForFrameThread.Start(); ShowpictureBoxCamera.Refresh(); }
private void ShowpictureBoxCamera_Resize(object sender, EventArgs e) { ShowpictureBoxCamera.Refresh(); }