Exemplo n.º 1
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;
    }