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(
|
self._data_dir = os.path.join(
|
||||||
os.path.normpath(str(app_data_dir)), os.path.normpath(self.name)
|
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
|
return self
|
||||||
|
|
||||||
def __exit__(
|
def __exit__(
|
||||||
|
|
|
||||||
|
|
@ -737,11 +737,9 @@ class AutofocusThing(lt.Thing):
|
||||||
|
|
||||||
# Loop through the range, saving each capture to disk
|
# Loop through the range, saving each capture to disk
|
||||||
for capture in captures[slice_to_save]:
|
for capture in captures[slice_to_save]:
|
||||||
self._cam.save_from_memory(
|
path = os.path.join(capture_parameters.images_dir, capture.filename)
|
||||||
jpeg_path=os.path.join(capture_parameters.images_dir, capture.filename),
|
self._cam.save_from_memory(path=path, buffer_id=capture.buffer_id)
|
||||||
save_resolution=capture_parameters.save_resolution,
|
|
||||||
buffer_id=capture.buffer_id,
|
|
||||||
)
|
|
||||||
self._cam.clear_buffers()
|
self._cam.clear_buffers()
|
||||||
return sharpest_index
|
return sharpest_index
|
||||||
|
|
||||||
|
|
@ -823,7 +821,9 @@ class AutofocusThing(lt.Thing):
|
||||||
camera buffer_id needed for saving.
|
camera buffer_id needed for saving.
|
||||||
"""
|
"""
|
||||||
stage_location = self._stage.position
|
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(
|
return CaptureInfo(
|
||||||
buffer_id=buffer_id,
|
buffer_id=buffer_id,
|
||||||
position=stage_location,
|
position=stage_location,
|
||||||
|
|
@ -956,14 +956,8 @@ class AutofocusThing(lt.Thing):
|
||||||
|
|
||||||
# Save all captures
|
# Save all captures
|
||||||
for capture in captures:
|
for capture in captures:
|
||||||
self._cam.save_from_memory(
|
path = os.path.join(capture_parameters.images_dir, capture.filename)
|
||||||
jpeg_path=os.path.join(
|
self._cam.save_from_memory(path=path, buffer_id=capture.buffer_id)
|
||||||
capture_parameters.images_dir,
|
|
||||||
capture.filename,
|
|
||||||
),
|
|
||||||
save_resolution=capture_parameters.save_resolution,
|
|
||||||
buffer_id=capture.buffer_id,
|
|
||||||
)
|
|
||||||
|
|
||||||
self._cam.clear_buffers()
|
self._cam.clear_buffers()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -164,9 +164,9 @@ class ScanWorkflow(Generic[SettingModelType], lt.Thing):
|
||||||
self._autofocus.fast_autofocus(dz=dz)
|
self._autofocus.fast_autofocus(dz=dz)
|
||||||
focus_height = self._stage.get_xyz_position()[2]
|
focus_height = self._stage.get_xyz_position()[2]
|
||||||
filename = f"img_{xyz_pos[0]}_{xyz_pos[1]}_{focus_height}.jpeg"
|
filename = f"img_{xyz_pos[0]}_{xyz_pos[1]}_{focus_height}.jpeg"
|
||||||
self._cam.capture_and_save(
|
self._cam.capture_and_save_to_path(
|
||||||
jpeg_path=os.path.join(images_dir, filename),
|
path=os.path.join(images_dir, filename),
|
||||||
save_resolution=save_resolution,
|
capture_mode="standard",
|
||||||
)
|
)
|
||||||
|
|
||||||
return True, focus_height
|
return True, focus_height
|
||||||
|
|
|
||||||
|
|
@ -197,9 +197,6 @@ class RangeofMotionThing(OFMThing):
|
||||||
"time": total_time,
|
"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")
|
timestamp = datetime.now().strftime("%Y_%m_%d_%H_%M")
|
||||||
datafile_path = os.path.join(self.data_dir, f"rom_data_{timestamp}.json")
|
datafile_path = os.path.join(self.data_dir, f"rom_data_{timestamp}.json")
|
||||||
with open(datafile_path, "w", encoding="utf-8") as f:
|
with open(datafile_path, "w", encoding="utf-8") as f:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue