From 9a751def17f56495113ea53a90c8081fbde9a6f1 Mon Sep 17 00:00:00 2001 From: sebb-oh <167853786+sebb-oh@users.noreply.github.com> Date: Wed, 17 Jul 2024 15:50:37 +0200 Subject: [PATCH] Update main.py - Fixing image saving: FileFormat was just changing the file suffix, not the actual image format, resulting in naming JPEGs .png - Added all supported file formats to the selection --- src/Camera-Basler_pylon/main.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Camera-Basler_pylon/main.py b/src/Camera-Basler_pylon/main.py index ad0197db..b8aa63ed 100644 --- a/src/Camera-Basler_pylon/main.py +++ b/src/Camera-Basler_pylon/main.py @@ -91,7 +91,7 @@ def set_GUIparameter(self) -> dict: # noqa: N802 # "GainAuto": ["Off"], # not needed # "ExposureAuto": ["Off"], # not needed "PixelFormat": "", - "FileFormat": ["jpeg", "png"], + "FileFormat": ["jpeg", "png", "bmp", "tiff", "raw"], "Gamma": 1, "ExposureTime": 10, "Gain": 1, @@ -216,7 +216,16 @@ def measure(self) -> None: img.AttachGrabResultBuffer(grab_result) # Save the image data. - img.Save(pylon.ImageFileFormat_Jpeg, self.save_path) + if self.file_format == "jpeg": + img.Save(pylon.ImageFileFormat_Jpeg, self.save_path) + elif self.file_format == "png": + img.Save(pylon.ImageFileFormat_Png, self.save_path) + elif self.file_format == "bmp": + img.Save(pylon.ImageFileFormat_Bmp, self.save_path) + elif self.file_format == "tiff": + img.Save(pylon.ImageFileFormat_Tiff, self.save_path) + elif self.file_format == "raw": + img.Save(pylon.ImageFileFormat_Raw, self.save_path) else: print("Error: ", grab_result.ErrorCode, grab_result.ErrorDescription) grab_result.Release()