Fixed picamera setup
This commit is contained in:
parent
7458d278d8
commit
265eed7bfa
4 changed files with 18 additions and 21 deletions
|
|
@ -21,8 +21,8 @@ def recalibrate(microscope):
|
||||||
"""
|
"""
|
||||||
scamera = microscope.camera
|
scamera = microscope.camera
|
||||||
with scamera.lock:
|
with scamera.lock:
|
||||||
assert not scamera.status["record_active"], "Can't recalibrate while recording!"
|
assert not scamera.record_active, "Can't recalibrate while recording!"
|
||||||
streaming = scamera.status["stream_active"]
|
streaming = scamera.stream_active
|
||||||
if streaming:
|
if streaming:
|
||||||
logging.info("Stopping stream before recalibration")
|
logging.info("Stopping stream before recalibration")
|
||||||
scamera.stop_stream_recording(resolution=(640, 480))
|
scamera.stop_stream_recording(resolution=(640, 480))
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class MoveStageAPI(View):
|
||||||
logging.warning("Unable to move. No stage found.")
|
logging.warning("Unable to move. No stage found.")
|
||||||
|
|
||||||
# TODO: Make schema for microscope status
|
# TODO: Make schema for microscope status
|
||||||
return jsonify(microscope.status["stage"]["position"])
|
return jsonify(microscope.state["stage"]["position"])
|
||||||
|
|
||||||
|
|
||||||
@ThingAction
|
@ThingAction
|
||||||
|
|
|
||||||
|
|
@ -333,13 +333,13 @@ class PiCameraStreamer(BaseCamera):
|
||||||
Change the camera zoom, handling re-centering and scaling.
|
Change the camera zoom, handling re-centering and scaling.
|
||||||
"""
|
"""
|
||||||
with self.lock:
|
with self.lock:
|
||||||
self.status["zoom_value"] = float(zoom_value)
|
self.zoom_value = float(zoom_value)
|
||||||
if self.status["zoom_value"] < 1:
|
if self.zoom_value < 1:
|
||||||
self.status["zoom_value"] = 1
|
self.zoom_value = 1
|
||||||
# Richard's code for zooming !
|
# Richard's code for zooming !
|
||||||
fov = self.camera.zoom
|
fov = self.camera.zoom
|
||||||
centre = np.array([fov[0] + fov[2] / 2.0, fov[1] + fov[3] / 2.0])
|
centre = np.array([fov[0] + fov[2] / 2.0, fov[1] + fov[3] / 2.0])
|
||||||
size = 1.0 / self.status["zoom_value"]
|
size = 1.0 / self.zoom_value
|
||||||
# If the new zoom value would be invalid, move the centre to
|
# If the new zoom value would be invalid, move the centre to
|
||||||
# keep it within the camera's sensor (this is only relevant
|
# keep it within the camera's sensor (this is only relevant
|
||||||
# when zooming out, if the FoV is not centred on (0.5, 0.5)
|
# when zooming out, if the FoV is not centred on (0.5, 0.5)
|
||||||
|
|
@ -552,7 +552,7 @@ class PiCameraStreamer(BaseCamera):
|
||||||
if isinstance(output, CaptureObject):
|
if isinstance(output, CaptureObject):
|
||||||
target = output.file
|
target = output.file
|
||||||
else:
|
else:
|
||||||
target = target
|
target = output
|
||||||
|
|
||||||
with self.lock:
|
with self.lock:
|
||||||
logging.info("Capturing to {}".format(output))
|
logging.info("Capturing to {}".format(output))
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ class Microscope:
|
||||||
### Detector
|
### Detector
|
||||||
if configuration.get("camera"):
|
if configuration.get("camera"):
|
||||||
camera_type = configuration["camera"].get("type")
|
camera_type = configuration["camera"].get("type")
|
||||||
if camera_type == "PiCamera" or camera_type == "PiCameraStreamer":
|
if camera_type in ("PiCamera", "PiCameraStreamer"):
|
||||||
try:
|
try:
|
||||||
self.camera = PiCameraStreamer()
|
self.camera = PiCameraStreamer()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -87,12 +87,8 @@ class Microscope:
|
||||||
if configuration.get("stage"):
|
if configuration.get("stage"):
|
||||||
stage_type = configuration["stage"].get("type")
|
stage_type = configuration["stage"].get("type")
|
||||||
stage_port = configuration["stage"].get("port")
|
stage_port = configuration["stage"].get("port")
|
||||||
if stage_type == "SangaBoard" or camera_type == "SangaStage":
|
if stage_type in ("SangaBoard", "SangaStage"):
|
||||||
try:
|
self.stage = SangaStage(port=stage_port)
|
||||||
self.stage = SangaStage(port=stage_port)
|
|
||||||
except Exception as e:
|
|
||||||
logging.error(e)
|
|
||||||
logging.warning("No compatible stage hardware found.")
|
|
||||||
|
|
||||||
### Fallbacks
|
### Fallbacks
|
||||||
if not self.camera:
|
if not self.camera:
|
||||||
|
|
@ -180,13 +176,14 @@ class Microscope:
|
||||||
# Read LST. Returns None if no LST is active
|
# Read LST. Returns None if no LST is active
|
||||||
lst_arr = self.camera.read_lens_shading_table()
|
lst_arr = self.camera.read_lens_shading_table()
|
||||||
|
|
||||||
b64_string, dtype, shape = serialise_array_b64(lst_arr)
|
if lst_arr:
|
||||||
|
b64_string, dtype, shape = serialise_array_b64(lst_arr)
|
||||||
|
|
||||||
settings_current["camera"]["lens_shading_table"] = {
|
settings_current["camera"]["lens_shading_table"] = {
|
||||||
"b64_string": b64_string,
|
"b64_string": b64_string,
|
||||||
"dtype": dtype,
|
"dtype": dtype,
|
||||||
"shape": shape,
|
"shape": shape,
|
||||||
}
|
}
|
||||||
|
|
||||||
# If attached to a stage
|
# If attached to a stage
|
||||||
if self.stage:
|
if self.stage:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue