Fix API gphoto2 pour python-gphoto2 v2.5+ (suppression contexte)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -75,9 +75,8 @@ class Camera:
|
||||
if source == "gphoto2" or source is None:
|
||||
if GPHOTO2_DISPONIBLE:
|
||||
try:
|
||||
self.contexte = gp.Context()
|
||||
self.camera = gp.Camera()
|
||||
self.camera.init(self.contexte)
|
||||
self.camera.init()
|
||||
self.connectee = True
|
||||
self.mode = "gphoto2"
|
||||
log.info("Camera DSLR connectee")
|
||||
@@ -116,7 +115,7 @@ class Camera:
|
||||
"""Deconnecte l'appareil photo."""
|
||||
if self.camera and GPHOTO2_DISPONIBLE:
|
||||
try:
|
||||
self.camera.exit(self.contexte)
|
||||
self.camera.exit()
|
||||
except gp.GPhoto2Error:
|
||||
pass
|
||||
if self.webcam:
|
||||
@@ -148,9 +147,10 @@ class Camera:
|
||||
|
||||
def _capture_gphoto2(self, chemin_dest: Path) -> Path | None:
|
||||
try:
|
||||
chemin_camera = self.camera.capture(gp.GP_CAPTURE_IMAGE, self.contexte)
|
||||
fichier_camera = self.camera.file_get(
|
||||
chemin_camera.folder, chemin_camera.name, gp.GP_FILE_TYPE_NORMAL, self.contexte
|
||||
chemin_camera = self.camera.capture(gp.GP_CAPTURE_IMAGE)
|
||||
fichier_camera = gp.CameraFile()
|
||||
self.camera.file_get(
|
||||
chemin_camera.folder, chemin_camera.name, gp.GP_FILE_TYPE_NORMAL, fichier_camera
|
||||
)
|
||||
fichier_camera.save(str(chemin_dest))
|
||||
log.info(f"Photo capturee (DSLR) : {chemin_dest}")
|
||||
@@ -184,7 +184,7 @@ class Camera:
|
||||
|
||||
def _preview_gphoto2(self) -> bytes | None:
|
||||
try:
|
||||
fichier = self.camera.capture_preview(self.contexte)
|
||||
fichier = self.camera.capture_preview()
|
||||
donnees = fichier.get_data_and_size()
|
||||
return bytes(donnees)
|
||||
except gp.GPhoto2Error as e:
|
||||
@@ -215,8 +215,7 @@ class Camera:
|
||||
# DSLR via gphoto2
|
||||
if GPHOTO2_DISPONIBLE:
|
||||
try:
|
||||
ctx = self.contexte or gp.Context()
|
||||
dslrs = gp.Camera.autodetect(ctx)
|
||||
dslrs = gp.Camera.autodetect()
|
||||
for nom, port in dslrs:
|
||||
appareils.append({
|
||||
"nom": f"{nom} ({port})",
|
||||
|
||||
Reference in New Issue
Block a user