Preview DSLR : resize 960px + base64 hors asyncio pour fluidifier liveview
This commit is contained in:
@@ -200,8 +200,19 @@ class Camera:
|
||||
def _preview_gphoto2(self) -> bytes | None:
|
||||
try:
|
||||
fichier = self.camera.capture_preview()
|
||||
donnees = fichier.get_data_and_size()
|
||||
return bytes(donnees)
|
||||
donnees = bytes(fichier.get_data_and_size())
|
||||
# Redimensionner pour alléger le WebSocket
|
||||
img = cv2.imdecode(
|
||||
__import__("numpy").frombuffer(donnees, dtype=__import__("numpy").uint8),
|
||||
cv2.IMREAD_COLOR,
|
||||
)
|
||||
if img is not None:
|
||||
h, w = img.shape[:2]
|
||||
if w > 960:
|
||||
img = cv2.resize(img, (960, int(h * 960 / w)), interpolation=cv2.INTER_LINEAR)
|
||||
_, buf = cv2.imencode(".jpg", img, [cv2.IMWRITE_JPEG_QUALITY, 75])
|
||||
return buf.tobytes()
|
||||
return donnees
|
||||
except gp.GPhoto2Error as e:
|
||||
log.error(f"Erreur preview DSLR : {e}")
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user