Start to move rest of python onto refactored camera API
This commit is contained in:
parent
e3361ebec8
commit
c18d43a3a5
4 changed files with 13 additions and 20 deletions
|
|
@ -34,6 +34,8 @@ class OFMThing(lt.Thing):
|
|||
self._data_dir = os.path.join(
|
||||
os.path.normpath(str(app_data_dir)), os.path.normpath(self.name)
|
||||
)
|
||||
if not os.path.exists(self.data_dir):
|
||||
os.makedirs(self.data_dir)
|
||||
return self
|
||||
|
||||
def __exit__(
|
||||
|
|
|
|||
|
|
@ -737,11 +737,9 @@ class AutofocusThing(lt.Thing):
|
|||
|
||||
# Loop through the range, saving each capture to disk
|
||||
for capture in captures[slice_to_save]:
|
||||
self._cam.save_from_memory(
|
||||
jpeg_path=os.path.join(capture_parameters.images_dir, capture.filename),
|
||||
save_resolution=capture_parameters.save_resolution,
|
||||
buffer_id=capture.buffer_id,
|
||||
)
|
||||
path = os.path.join(capture_parameters.images_dir, capture.filename)
|
||||
self._cam.save_from_memory(path=path, buffer_id=capture.buffer_id)
|
||||
|
||||
self._cam.clear_buffers()
|
||||
return sharpest_index
|
||||
|
||||
|
|
@ -823,7 +821,9 @@ class AutofocusThing(lt.Thing):
|
|||
camera buffer_id needed for saving.
|
||||
"""
|
||||
stage_location = self._stage.position
|
||||
buffer_id = self._cam.capture_to_memory(buffer_max=buffer_max)
|
||||
buffer_id = self._cam.capture_to_memory(
|
||||
capture_mode="standard", buffer_max=buffer_max
|
||||
)
|
||||
return CaptureInfo(
|
||||
buffer_id=buffer_id,
|
||||
position=stage_location,
|
||||
|
|
@ -956,14 +956,8 @@ class AutofocusThing(lt.Thing):
|
|||
|
||||
# Save all captures
|
||||
for capture in captures:
|
||||
self._cam.save_from_memory(
|
||||
jpeg_path=os.path.join(
|
||||
capture_parameters.images_dir,
|
||||
capture.filename,
|
||||
),
|
||||
save_resolution=capture_parameters.save_resolution,
|
||||
buffer_id=capture.buffer_id,
|
||||
)
|
||||
path = os.path.join(capture_parameters.images_dir, capture.filename)
|
||||
self._cam.save_from_memory(path=path, buffer_id=capture.buffer_id)
|
||||
|
||||
self._cam.clear_buffers()
|
||||
|
||||
|
|
|
|||
|
|
@ -164,9 +164,9 @@ class ScanWorkflow(Generic[SettingModelType], lt.Thing):
|
|||
self._autofocus.fast_autofocus(dz=dz)
|
||||
focus_height = self._stage.get_xyz_position()[2]
|
||||
filename = f"img_{xyz_pos[0]}_{xyz_pos[1]}_{focus_height}.jpeg"
|
||||
self._cam.capture_and_save(
|
||||
jpeg_path=os.path.join(images_dir, filename),
|
||||
save_resolution=save_resolution,
|
||||
self._cam.capture_and_save_to_path(
|
||||
path=os.path.join(images_dir, filename),
|
||||
capture_mode="standard",
|
||||
)
|
||||
|
||||
return True, focus_height
|
||||
|
|
|
|||
|
|
@ -197,9 +197,6 @@ class RangeofMotionThing(OFMThing):
|
|||
"time": total_time,
|
||||
}
|
||||
|
||||
if not os.path.exists(self.data_dir):
|
||||
os.makedirs(self.data_dir)
|
||||
|
||||
timestamp = datetime.now().strftime("%Y_%m_%d_%H_%M")
|
||||
datafile_path = os.path.join(self.data_dir, f"rom_data_{timestamp}.json")
|
||||
with open(datafile_path, "w", encoding="utf-8") as f:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue