private void SelectedCGCameraDevice() { if (IntPtr.Zero != mDeviceHandle) { CGAPI.DeviceStop(mDeviceHandle); CGAPI.SyncCloseDevice(mDeviceHandle); CGAPI.DeviceUnInit(mDeviceHandle); CGAPI.DeviceRelease(mDeviceHandle); mDeviceHandle = IntPtr.Zero; } else { byte byDev = 1; DeviceStatus devStatus = CGAPI.OpenDeviceByUSBAddress(byDev, ref mDeviceHandle); if (DeviceStatus.STATUS_OK == devStatus) { ReceiveFrameProc rfCallBack = new ReceiveFrameProc(OnReceiveFrame); //不添加回调函数. //devStatus = CGAPI.DeviceInit(mDeviceHandle, panelVideo.Handle, false, true); //添加回调函数. //devStatus = CGAPI.DeviceInitEx(mDeviceHandle, rfCallBack, IntPtr.Zero, panelVideo.Handle, true); devStatus = CGAPI.DeviceInitEx(mDeviceHandle, rfCallBack, IntPtr.Zero, IntPtr.Zero, true); if (DeviceStatus.STATUS_OK == devStatus) { Debug.Log("Open CGCamera..."); } } } }
public void CloseCGCamera() { if (mDeviceHandle != IntPtr.Zero) { Debug.Log("CloseCGCamera..."); CGAPI.DeviceStop(mDeviceHandle); CGAPI.CloseDevice(mDeviceHandle); CGAPI.DeviceUnInit(mDeviceHandle); CGAPI.DeviceRelease(mDeviceHandle); mDeviceHandle = IntPtr.Zero; CGAPI.DeviceUnInitialSDK(); } }
public bool CloseCamera() { if (this.IsOpen) { CGAPI.Stop(mDeviceHandle); CGAPI.CloseDevice(mDeviceHandle); CGAPI.DeviceUnInit(mDeviceHandle); CGAPI.DeviceRelease(mDeviceHandle); mDeviceHandle = IntPtr.Zero; CGAPI.DeviceUnInitialSDK(); } return(true); }