Apply suggestions from code review of branch jpeg-capture-in-stacking
Co-authored-by: Beth Probert <beth_probert@outlook.com>
This commit is contained in:
parent
2d49bf2061
commit
0933ece63a
8 changed files with 43 additions and 15 deletions
|
|
@ -294,6 +294,7 @@ class AutofocusThing(Thing):
|
|||
|
||||
stack_z_range = stack_dz * (images_to_capture - 1)
|
||||
if stack_z_range > 0:
|
||||
# Perform backlash corrected move. See issue #420
|
||||
stage.move_relative(z=-(STACK_OVERSHOOT + stack_z_range / 2))
|
||||
stage.move_relative(z=STACK_OVERSHOOT)
|
||||
time.sleep(0.3)
|
||||
|
|
@ -348,7 +349,7 @@ class AutofocusThing(Thing):
|
|||
images_dir: str,
|
||||
stack_dir: str,
|
||||
logger: InvocationLogger,
|
||||
):
|
||||
) -> None:
|
||||
"""Gets a list of images in a folder (stack_dir), sorts them by filesize, and copies the sharpest
|
||||
image to images dir."""
|
||||
image_list = glob.glob(os.path.join(stack_dir, "*"))
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ class JPEGBlob(Blob):
|
|||
|
||||
|
||||
class PNGBlob(Blob):
|
||||
"""A class representing a PNG image as a LabThings FastAPI Blob"""
|
||||
|
||||
media_type: str = "image/png"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -377,10 +377,13 @@ class SmartScanThing(Thing):
|
|||
return (next_point[0], next_point[1], z_estimate)
|
||||
|
||||
@_scan_running
|
||||
def _calc_displacement_from_test_image(self, overlap):
|
||||
def _calc_displacement_from_test_image(self, overlap: int) -> tuple[int, int]:
|
||||
"""
|
||||
Take a test image and use camera stage mapping to calculate x and y displacement
|
||||
|
||||
:param overlap: The desired overlap as a fraction of the image. i.e. 0.5 means
|
||||
that each image should overlap its nearest neighbour by 50%.
|
||||
|
||||
Return (dx, dy) - the x and y displacments in steps
|
||||
"""
|
||||
test_jpg = self._cam.grab_jpeg()
|
||||
|
|
@ -422,7 +425,9 @@ class SmartScanThing(Thing):
|
|||
dx, dy = self._calc_displacement_from_test_image(overlap)
|
||||
stitch_resize = STITCHING_RESOLUTION[0] / self.capture_resolution[0]
|
||||
|
||||
self._scan_logger.debug(f"Resizing images when stitching by {stitch_resize}")
|
||||
self._scan_logger.debug(
|
||||
f"Resizing images when stitching by a factor of {stitch_resize}"
|
||||
)
|
||||
|
||||
self._scan_logger.info(
|
||||
f"Based on an overlap of {overlap}, we will make steps of {dx}, {dy}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue