Python utilities for controlling Daheng cameras from WSL. The repo contains:
main.py– interactive viewer for previewing, saving frames, and recording video streams.multi_exp_image.py– scripted capture pipeline that records multiple exposures and fuses them into an HDR output.
- Works with Daheng cameras via
gxipy - Interactive controls (save frame, toggle recording, quit)
- HDR workflow using OpenCV’s Debevec + Drago operators
- Ready-to-run instructions for WSL + USB/IP setup
- Windows 11 with WSL2 (Ubuntu recommended)
- Daheng Galaxy SDK for Linux
- Python 3.10+ with
gxipy,opencv-python,numpy - USB/IP tooling (
usbipd-win) to pass the camera through to WSL
WSL is its own Linux environment, so Windows .dll files are not usable. Install the Linux SDK inside WSL to provide the libgxiapi.so shared object.
- Download the Linux SDK (
Galaxy_Linux-x86_Gige-U3_*.runor.tar.gz) from the Daheng Imaging Download Center. - Copy it into WSL (replace the username as needed):
cp /mnt/c/Users/<username>/Downloads/Galaxy_Linux*.run ~/ cd ~
- Make the installer executable:
chmod +x Galaxy_Linux-x86_Gige-U3_*.run - Run it with sudo and follow the prompts (default path is
/opt/DxImageCard/Galaxy_SDK/):sudo ./Galaxy_Linux-x86_Gige-U3_*.run - Let Linux know where to find
libgxiapi.so:export LD_LIBRARY_PATH=/opt/DxImageCard/Galaxy_SDK/lib:$LD_LIBRARY_PATH echo 'export LD_LIBRARY_PATH=/opt/DxImageCard/Galaxy_SDK/lib:$LD_LIBRARY_PATH' >> ~/.bashrc source ~/.bashrc
Run these PowerShell commands as Administrator on Windows:
usbipd list
usbipd bind --busid <BUSID> --force
usbipd attach --wsl --busid <BUSID>Then in WSL verify visibility with:
lsusb- Create and activate a virtual environment (optional but recommended).
- Install Python dependencies:
pip install -r requirements.txt # or manually install gxipy, opencv-python, numpy - Confirm the camera is detected:
python - <<'PY' import gxipy as gx dm = gx.DeviceManager() print("Cameras:", dm.update_device_list()[0]) PY
python main.pyControls:
s– save current frame tooutput/r– toggle AVI recordingq– quit and close the camera
Customize capture settings (exposure, gain, frame size, save path) at the top of the script.
python multi_exp_image.pyThis script:
- Captures a bracketed exposure series (tweak
exposure_timesin the script). - Writes images to
output_images/. - Merges them into
output_images/hdr_image.png.
Cannot find libgxiapi.so– ensure the SDK is installed in WSL andLD_LIBRARY_PATHincludes itslibdirectory.NameError: 'dll'– consequence of the missing library above; fix the library path.- Camera not detected – reattach with
usbipd, confirm withlsusb, then re-run the Python script.
Happy capturing!