Autofocus tweaks for smart scan
We've removed the initial double-autofocus (we just do a single looping autofocus at the start), and now only do 3 retries rather than 5 if the focus is rejected.
This commit is contained in:
parent
20efaa2799
commit
924cce649a
1 changed files with 2 additions and 8 deletions
|
|
@ -439,9 +439,6 @@ class SmartScanThing(Thing):
|
||||||
os.mkdir(raw_images_folder)
|
os.mkdir(raw_images_folder)
|
||||||
logger.info(f"Saving images to {images_folder}")
|
logger.info(f"Saving images to {images_folder}")
|
||||||
|
|
||||||
# TODO: I think this is unnecessary, we do a looping autofocus at the first point in the loop, unless
|
|
||||||
# it's flagged as background (which is a wierd case anyway)
|
|
||||||
recentre.looping_autofocus()
|
|
||||||
# move to each x-y position. in z, move to the height of the closest x-y position that successfully focused
|
# move to each x-y position. in z, move to the height of the closest x-y position that successfully focused
|
||||||
while len(path) > 0:
|
while len(path) > 0:
|
||||||
ensure_free_disk_space(scan_folder)
|
ensure_free_disk_space(scan_folder)
|
||||||
|
|
@ -512,15 +509,12 @@ class SmartScanThing(Thing):
|
||||||
loc = list(stage.position.values())
|
loc = list(stage.position.values())
|
||||||
focused_path.append(loc)
|
focused_path.append(loc)
|
||||||
break
|
break
|
||||||
if attempts >= 5:
|
if attempts >= 3:
|
||||||
logger.warning("Could not autofocus after 5 attempts.")
|
logger.warning("Could not autofocus after 5 attempts.")
|
||||||
break
|
break
|
||||||
# if the autofocus was rejected, we return to the height of the closest successful autofocus. not perfect, but better than wandering out of focus
|
# if the autofocus was rejected, we return to the height of the closest successful autofocus. not perfect, but better than wandering out of focus
|
||||||
logger.info(
|
logger.info(
|
||||||
"The focus seems to have moved farther than we expect. "
|
"The focus has shifted further than we expect: retrying."
|
||||||
"We will now rest the Z position and try again. "
|
|
||||||
f"Options are {focused_path}, we chose "
|
|
||||||
f"{nearest_focused_site}"
|
|
||||||
)
|
)
|
||||||
stage.move_absolute(z=int(focused_path[z_index][2]))
|
stage.move_absolute(z=int(focused_path[z_index][2]))
|
||||||
attempts += 1
|
attempts += 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue