Initialization Issue with Daheng Camera in imswitch

Hello, @benedictdied

I encountered an issue while using the imswitch software with a Daheng camera. My camera configuration follows:

"detectors":{
        "WidefieldCamera":{
           "ExtPackage":"imswitch_det_webcam",
           "analogChannel":null,
           "digitalLine":null,
           "managerName":"GXPIPYManager",
           "managerProperties":{
              "cameraListIndex":1,
              "cameraEffPixelsize":0.45,
              "gxipycam":{
                 "exposure":20,
                 "gain":0,
                 "blacklevel":10,
                 "image_width":1000,
                 "image_height":1000
              }
           },
           "forAcquisition":true,
           "forFocusLock":true
        }
     }, 

and the error log shows

2024-08-19 16:36:55 DEBUG [GXPIPYManager -> WidefieldCamera] This sample does not support color camera.
DEBUG:imswitch:[GXPIPYManager -> WidefieldCamera] This sample does not support color camera.
2024-08-19 16:36:56 INFO [GXPIPYManager -> WidefieldCamera] Initialized camera, model: CameraGXIPY
INFO:imswitch:[GXPIPYManager -> WidefieldCamera] Initialized camera, model: CameraGXIPY
2024-08-19 16:36:56 ERROR [DetectorsManager -> MultiManager] 'CameraGXIPY' object has no attribute 'SensorWidth'
ERROR:imswitch:[DetectorsManager -> MultiManager] 'CameraGXIPY' object has no attribute 'SensorWidth'
2024-08-19 16:36:56 ERROR [imcontrol init] Error initializing controller: 'WidefieldCamera'
ERROR:imswitch:[imcontrol init] Error initializing controller: 'WidefieldCamera'
2024-08-19 16:36:56 ERROR [main] Failed to initialize module imcontrol
ERROR:imswitch:[main] Failed to initialize module imcontrol
2024-08-19 16:36:56 ERROR [main] 'WidefieldCamera'
ERROR:imswitch:[main] 'WidefieldCamera'
2024-08-19 16:36:56 ERROR [main] Traceback (most recent call last):
  File "C:\Users\lihai\Downloads\imswitch\imswitch\__main__.py", line 149, in main
    view, controller = modulePkg.getMainViewAndController(
  File "C:\Users\lihai\Downloads\imswitch\imswitch\imcontrol\__init__.py", line 89, in getMainViewAndController
    raise e
  File "C:\Users\lihai\Downloads\imswitch\imswitch\imcontrol\__init__.py", line 84, in getMainViewAndController
    controller = ImConMainController(options, setupInfo, view, moduleCommChannel)
  File "C:\Users\lihai\Downloads\imswitch\imswitch\imcontrol\controller\ImConMainController.py", line 32, in __init__
    self.__masterController = MasterController(self.__setupInfo, self.__commChannel,
  File "C:\Users\lihai\Downloads\imswitch\imswitch\imcontrol\controller\MasterController.py", line 34, in __init__
    self.detectorsManager = DetectorsManager(self.__setupInfo.detectors, updatePeriod=100,
  File "C:\Users\lihai\Downloads\imswitch\imswitch\imcontrol\model\managers\DetectorsManager.py", line 31, in __init__
    if not self._subManagers[detectorName].forAcquisition:
KeyError: 'WidefieldCamera'

Did I make any mistakes when configuring the Daheng camera? Thank you for your help.

It’s due to the Colour Sensor. Let’s review this. I haven’t implemented this yet. Shouldn’t be too difficult.

Turned out that the colour mode was a bit more involved. Fixed it now :slight_smile:

You would need the following configuration for ImSwitch inside the detector bit of the json file:

  "detectors": {
    "WidefieldCamera": {
      "analogChannel": null,
      "digitalLine": null,
      "managerName": "GXPIPYManager",
      "managerProperties": {
        "cameraListIndex": 1,
        "cameraEffPixelsize": 0.2257,
        "isRGB": 1,        
        "gxipycam": {
          "exposure": 20,
          "gain": 0,
          "blacklevel": 10,
          "image_width": 1000,
          "image_height": 1000
        }
      },
      "forAcquisition": true,
      "forFocusLock": true
    }
  },