Files
lights/gphoto2_bridge.py
T
2026-07-12 22:29:30 -07:00

36 lines
916 B
Python

"""
Filename: gphoto2_bridge.py
Description: Polls cameras using gphoto2 with seperate python interpreter
Author: Tyler de Zeeuw
License: GPL-3.0
"""
# Built-in imports
import os
import sys
import traceback
PWD = os.path.dirname(os.path.abspath(__file__))
MSYS2_BIN = str(PWD) + r"\res_gphoto2\bin"
MSYS2_CAMLIBS = str(PWD) + r"\res_gphoto2\lib\libgphoto2\2.5.34"
MSYS2_IOLIBS = str(PWD) + r"\res_gphoto2\lib\libgphoto2_port\0.12.2"
os.environ["IOLIBS"] = MSYS2_IOLIBS
os.environ["PATH"] = MSYS2_BIN + os.pathsep + os.environ.get("PATH", "")
os.environ["CAMLIBS"] = MSYS2_CAMLIBS
try:
import gphoto2 as gp
context = gp.Context()
camera_list = gp.Camera.autodetect(context)
detected = [(name, port) for name, port in camera_list]
print(repr(detected))
except Exception as e:
print(f"BRIDGE_ERROR: {type(e).__name__}: {str(e)}")
traceback.print_exc(file=sys.stderr)
sys.exit(1)