diff --git a/picamera2/picamera2.py b/picamera2/picamera2.py index 836142c6..a0fb76a6 100644 --- a/picamera2/picamera2.py +++ b/picamera2/picamera2.py @@ -1202,7 +1202,7 @@ def dispatch_functions(self, functions, wait, signal_function=None, immediate=Fa self._run_process_requests() return job.get_result() if wait else job - def capture_file_(self, file_output, name: str, format=None, exif_data={}) -> dict: + def capture_file_(self, file_output, name: str, format=None, exif_data=None) -> dict: if not self.completed_requests: return (False, None) request = self.completed_requests.pop(0) @@ -1222,7 +1222,7 @@ def capture_file( format=None, wait=None, signal_function=None, - exif_data={}) -> dict: + exif_data=None) -> dict: """Capture an image to a file in the current camera mode. Return the metadata for the frame captured. @@ -1246,7 +1246,7 @@ def switch_mode(self, camera_config, wait=None, signal_function=None): return self.dispatch_functions(functions, wait, signal_function, immediate=True) def switch_mode_and_capture_file(self, camera_config, file_output, name="main", format=None, - wait=None, signal_function=None, exif_data={}): + wait=None, signal_function=None, exif_data=None): """Switch the camera into a new (capture) mode, capture an image to file. Then return back to the initial camera mode. @@ -1265,7 +1265,7 @@ def capture_and_switch_back_(self, file_output, preview_config, format, exif_dat functions = [partial(self.switch_mode_, camera_config), partial(capture_and_switch_back_, self, file_output, preview_config, format, - exif_data=exif_data})] + exif_data=exif_data)] return self.dispatch_functions(functions, wait, signal_function, immediate=True) def switch_mode_and_capture_request(self, camera_config, wait=None, signal_function=None): @@ -1629,7 +1629,7 @@ def set_overlay(self, overlay) -> None: def start_and_capture_files(self, name: str = "image{:03d}.jpg", initial_delay=1, preview_mode="preview", capture_mode="still", num_files=1, delay=1, - show_preview=True, exif_data={}): + show_preview=True, exif_data=None): """This function makes capturing multiple images more convenient. Should only be used in command line line applications (not from a Qt application, for example). diff --git a/picamera2/request.py b/picamera2/request.py index 945a1b94..83a5be92 100644 --- a/picamera2/request.py +++ b/picamera2/request.py @@ -162,13 +162,14 @@ def make_image(self, name, width=None, height=None): """Make a PIL image from the named stream's buffer.""" return self.picam2.helpers.make_image(self.make_buffer(name), self.config[name], width, height) - def save(self, name, file_output, format=None, exif_data={}): + def save(self, name, file_output, format=None, exif_data=None): """Save a JPEG or PNG image of the named stream's buffer. exif_data - dictionary containing user defined exif data (based on `piexif`). This will overwrite existing exif information generated by picamera2. """ - return self.picam2.helpers.save(self.make_image(name), self.get_metadata(), file_output, format) + return self.picam2.helpers.save(self.make_image(name), self.get_metadata(), file_output, + format, exif_data) def save_dng(self, filename, name="raw"): """Save a DNG RAW image of the raw stream's buffer.""" @@ -244,12 +245,14 @@ def make_image(self, buffer, config, width=None, height=None): pil_img = pil_img.resize((width, height)) return pil_img - def save(self, img, metadata, file_output, format=None, exif_data={}): + def save(self, img, metadata, file_output, format=None, exif_data=None): """Save a JPEG or PNG image of the named stream's buffer. exif_data - dictionary containing user defined exif data (based on `piexif`). This will overwrite existing exif information generated by picamera2. """ + if exif_data is None: + exif_data = {} # This is probably a hideously expensive way to do a capture. start_time = time.monotonic() exif = b''