Capture resolution as a Thing property
This commit is contained in:
parent
8c8c6568c3
commit
985d20e032
2 changed files with 17 additions and 6 deletions
|
|
@ -291,7 +291,7 @@ class AutofocusThing(Thing):
|
|||
capture: CaptureDep,
|
||||
images_dir: str,
|
||||
stack_dir: str,
|
||||
target_resolution: tuple[int, int],
|
||||
capture_resolution: tuple[int, int],
|
||||
) -> None:
|
||||
"""Run a z stack, saving all images to stack_dir and copying the
|
||||
central image to stack_dir"""
|
||||
|
|
@ -322,8 +322,8 @@ class AutofocusThing(Thing):
|
|||
if capture_count + 1 < images_to_capture:
|
||||
stage.move_relative(z=stack_dz)
|
||||
moved = time.time()
|
||||
if image.size != target_resolution:
|
||||
image = image.resize(target_resolution, Image.BOX)
|
||||
if image.size != capture_resolution:
|
||||
image = image.resize(capture_resolution, Image.BOX)
|
||||
downsampled = time.time()
|
||||
capture._save_capture(
|
||||
jpeg_path=jpeg_path,
|
||||
|
|
|
|||
|
|
@ -92,7 +92,6 @@ SCAN_DATA_FILENAME = "scan_data.json"
|
|||
STITCHING_CMD = "openflexure-stitch"
|
||||
|
||||
SCAN_ZERO_PAD_DIGITS = 4
|
||||
TARGET_RESOLUTION = (1640, 1232)
|
||||
STITCHING_RESOLUTION = (820, 616)
|
||||
|
||||
|
||||
|
|
@ -421,7 +420,7 @@ class SmartScanThing(Thing):
|
|||
"""
|
||||
overlap = self.overlap
|
||||
dx, dy = self._calc_displacement_from_test_image(overlap)
|
||||
stitch_resize = STITCHING_RESOLUTION[0] / TARGET_RESOLUTION[0]
|
||||
stitch_resize = STITCHING_RESOLUTION[0] / self.capture_resolution[0]
|
||||
|
||||
self._scan_logger.debug(f"Resizing images when stitching by {stitch_resize}")
|
||||
|
||||
|
|
@ -452,6 +451,7 @@ class SmartScanThing(Thing):
|
|||
"skip_background": self.skip_background,
|
||||
"stitch_automatically": self.stitch_automatically,
|
||||
"stitch_resize": stitch_resize,
|
||||
"capture_resolution": self.capture_resolution,
|
||||
}
|
||||
|
||||
@_scan_running
|
||||
|
|
@ -470,6 +470,7 @@ class SmartScanThing(Thing):
|
|||
"dy": self._scan_data["dy"],
|
||||
"start time": self._scan_data["start_time"],
|
||||
"skipping background": self._scan_data["skip_background"],
|
||||
"capture resolution": self._scan_data["capture_resolution"],
|
||||
}
|
||||
|
||||
scan_inputs_fname = os.path.join(
|
||||
|
|
@ -675,7 +676,7 @@ class SmartScanThing(Thing):
|
|||
self._autofocus.run_z_stack(
|
||||
images_dir=self._ongoing_scan_images_dir,
|
||||
stack_dir=site_folder,
|
||||
target_resolution=TARGET_RESOLUTION,
|
||||
capture_resolution=self._scan_data["capture_resolution"],
|
||||
)
|
||||
|
||||
# increment capure counter as thread has completed
|
||||
|
|
@ -744,6 +745,16 @@ class SmartScanThing(Thing):
|
|||
raise HTTPException(404, "File not found")
|
||||
return FileResponse(path)
|
||||
|
||||
@thing_property
|
||||
def capture_resolution(self) -> tuple[int, int]:
|
||||
"""A tuple of the image resolution to capture. Should be in a
|
||||
4:3 aspect ratio"""
|
||||
return self.thing_settings.get("capture_resolution", ((1640, 1232)))
|
||||
|
||||
@capture_resolution.setter
|
||||
def capture_resolution(self, value: tuple[int, int]) -> None:
|
||||
self.thing_settings["capture_resolution"] = value
|
||||
|
||||
@thing_property
|
||||
def max_range(self) -> int:
|
||||
"""The maximum distance from the centre of the scan before we break in steps"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue