public ThorlabSettings(ThorlabDevice cam) { camera = cam; }
private bool InitCamera() { m_uc480 = new ThorlabDevice(); settings = new ThorlabSettings(m_uc480); m_Uc480Images = new UC480IMAGE[IMAGE_COUNT]; if (m_uc480.InitCamera(1, hwnd.ToInt32()) != ThorlabDevice.IS_SUCCESS) { Console.Out.WriteLine("Thorlabs/UC480 Camera init failed"); return false; } // Load camera configuration file (if you change settings in the DLL/Native, // first build (Ctrl-Shift+B) so that it gets copied into the Bin folder) if (m_uc480.LoadParameters(parametersFileStr) != ThorlabDevice.IS_SUCCESS) Console.Out.WriteLine("UC480 Unable to load camera configuration file."); // Allocate memory for images AllocateImageMemory(settings.ROI.Width, settings.ROI.Height); // Set monochrome m_uc480.SetColorMode(ThorlabDevice.IS_SET_CM_Y8); //m_uc480.SetColorMode(ThorlabDevice.IS_SET_CM_BAYER); // enables on new frame event m_uc480.EnableMessage(ThorlabDevice.IS_FRAME, hwnd.ToInt32()); m_uc480.EnableMessage(ThorlabDevice.IS_DEVICE_RECONNECTED, hwnd.ToInt32()); m_uc480.EnableMessage(ThorlabDevice.IS_DEVICE_REMOVAL, hwnd.ToInt32()); m_uc480.EnableMessage(ThorlabDevice.IS_DEVICE_REMOVED, hwnd.ToInt32()); m_uc480.EnableMessage(ThorlabDevice.IS_DEVICE_RECONNECTED, hwnd.ToInt32()); return m_bLive; }
public ThorlabCamera() { // Must be set var curProc = Process.GetCurrentProcess(); this.hwndSource = HwndSource.FromHwnd(curProc.MainWindowHandle); this.hwnd = this.hwndSource.Handle; // Settings file // string dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase); var dir = GTPath.GetLocalApplicationDataPath(); var dirInfo = new DirectoryInfo(new Uri(dir).LocalPath); this.parametersFileStr = dirInfo.FullName + Path.DirectorySeparatorChar + this.defaultParametersFile; this.m_uc480 = new ThorlabDevice(); this.settings = new ThorlabSettings(this.m_uc480); this.Name = "Thorlabs UC480"; this.DetermineMaxFPS(); }
public ThorlabCamera() { // hwndSource must be set to addhook to messageloop for thorlab messages this.messageDummyWindow = new Window(); this.messageDummyWindow.Width = 1; this.messageDummyWindow.Height = 1; this.messageDummyWindow.Left = 2000; this.messageDummyWindow.Show(); var wih = new WindowInteropHelper(this.messageDummyWindow); this.hwndSource = HwndSource.FromHwnd(wih.Handle); if (this.hwndSource != null) { this.hwnd = this.hwndSource.Handle; } else { throw new Exception("HwndSource of Thorlabs=null"); } //var curProc = Process.GetCurrentProcess(); //this.hwndSource = HwndSource.FromHwnd(curProc.MainWindowHandle); //this.hwnd = this.hwndSource.Handle; // Settings file // string dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase); var dir = GTPath.GetLocalApplicationDataPath(); var dirInfo = new DirectoryInfo(new Uri(dir).LocalPath); this.parametersFileStr = dirInfo.FullName + Path.DirectorySeparatorChar + this.defaultParametersFile; this.m_uc480 = new ThorlabDevice(); this.settings = new ThorlabSettings(this.m_uc480); this.Name = "Thorlabs UC480"; this.DetermineMaxFPS(); }
public static bool IsConnected() { bool isConnected = false; log.Debug("IsConnected: Attempting to retrieve list of connected UC480 cameras..."); try { ThorlabDevice tempCam = new ThorlabDevice(); ThorlabDevice.UC480_CAMERA_LIST camList = new ThorlabDevice.UC480_CAMERA_LIST(); int list = tempCam.GetCameraList(ref camList); // if camera count is larger than 0 there is a UC camera connected.. if (camList.dwCount > 0) { log.Info("IsConnected: Detected " + camList.dwCount.ToString() + " UC480 camera(s) - ThorlabCamera.IsConnected will return 'true' - Thorlabs camera detected"); isConnected = true; } else { log.Info("IsConnected: Detected no UC480 camera(s) - ThorlabCamera.IsConnected will return 'false', i.e. No Thorlabs detected"); } tempCam = null; // it's not started or anything, just a reference for the method call above } catch (Exception ex) { log.Warn("IsConnected: Exception occurred whilst trying to detect Thorlabs camera (" + ex.Message + "), IsConnected will return 'false', i.e. No Thorlabs detected. Stack trace is: " + ex.StackTrace); } return isConnected; }