class CameraStageMapper(lt.Thing): (source)
A Thing to manage mapping between image and stage coordinates.
To use this Thing, the stage must have axes named "x", "y", and "z", or must override the get_xyz_position() and move_to_xyz_position() methods.
| Method | assert |
Raise an exception if the image_to_stage_displacement matrix is not set. |
| Method | calibrate |
Move a microscope's stage in 1D, and figure out the relationship with the camera. |
| Method | calibrate |
Move the microscope's stage in X and Y, to calibrate its relationship to the camera. |
| Method | move |
Move by a given number of pixels on the camera. |
| Instance Variable | last |
The most recent CSM calibration. |
| Property | image |
The image size used to calibrate the image_to_stage_displacement_matrix. |
| Property | image |
A 2x2 matrix that converts displacement in image coordinates to stage coordinates. |
| Property | thing |
Summary metadata describing the current state of the Thing. |
CameraClient, stage: Stage, logger: lt.deps.InvocationLogger, direction: tuple[ float, float, float]) -> DenumpifyingDict:
(source)
¶
Move a microscope's stage in 1D, and figure out the relationship with the camera.
CameraClient, stage: Stage, logger: lt.deps.InvocationLogger) -> DenumpifyingDict:
(source)
¶
Move the microscope's stage in X and Y, to calibrate its relationship to the camera.
This performs two 1d calibrations in x and y, then combines their results.
Move by a given number of pixels on the camera.
NB x and y here refer to what is usually understood to be the horizontal and vertical axes of the image. In many toolkits, "matrix indices" are used, which swap the order of these coordinates. This includes opencv and PIL. So, don't be surprised if you find it necessary to swap x and y around.
As a general rule, x usually corresponds to the longer dimension of the image, and y to the shorter one. Checking what shape your chosen toolkit reports for an image usually helps resolve any ambiguity.
A 2x2 matrix that converts displacement in image coordinates to stage coordinates.
Note that this matrix is defined using "matrix coordinates", i.e. image coordinates may be (y,x). This is an artifact of the way numpy, opencv, etc. define images. If you are making use of this matrix in your own code, you will need to take care of that conversion.
It is often helpful to give a concrete example: to make a move in image coordinates (dy, dx), where dx is horizontal, i.e. the longer dimension of the image, you should move the stage by:
stage_disp = np.dot(
np.array(image_to_stage_displacement_matrix),
np.array([dy,dx]),
)