示例#1
0
        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();
        }
示例#2
0
        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();
        }
示例#3
0
        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)

            // NIK

            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);
        }
示例#4
0
    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;
    }
示例#5
0
    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();
    }
示例#6
0
        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();
        }