pdcam module

The pdcam module provides camera support for the purpledrop. It provides video capture, as well as fiducial detection for image registration.

Currently, it supports the raspberry PI camera port, although it may be expanded in the future to support other cameras.

image_registration

Utilities for locating the electrode grid in an image

purpledrop.pdcam.image_registration.find_fiducials(image)[source]

Find april tag fiducials in an image and return them”

Parameters

image – An image in numpy array

Returns

A list of purpledrop.electrodeboard.Fiducial objects

purpledrop.pdcam.image_registration.find_grid_transform(image: <Mock name='mock.array' id='140472861676560'>, reference: typing.Optional[purpledrop.electrode_board.Registration] = None)[source]

Provide transform to move from electrode grid coordinates to pixel coordinates in a new image.

Parameters
  • image (numpy array) – An image of the reference board with all fiducials visible

  • reference – Control points and fiducials from a reference/calibration image

  • provided (of the electrode board. If not) –

  • to (an attempt will be made) –

  • boards. (look it up in the database of) –

purpledrop.pdcam.image_registration.find_reference_from_fiducials(search_labels: Tuple[int]) Optional[purpledrop.electrode_board.Registration][source]

Look for a board definition that matches the fiducial tags found

A matching board definition must include all of the fiducial labels, and it must be unique. It’s possible for multiple boards to match, in which case no reference is returned. Each of the provided fiducials must have a unique label, or no board can be matched.

This function is memoized to prevent searching boards on repeated image. This means that the process must be restarted if the board definition files are changed for the new data to take effect.

Parameters

search_labels – Tuple of integer labels for the fiducials to lookup

Returns

A Registration object if one is found, or None otherwise

purpledrop.pdcam.image_registration.sort_fiducials(qr_a, qr_b)[source]

Sort 2d fiducial markers in a consistent ordering based on their relative positions.

In general, when we find fiducials in an image, we don’t expect them to be returned in a consistent order. Additionally, the image coordinate may be rotated from image to image. Here we match fiducials by trying all permutations of matches and taking the best fit. We assume that the fiducials are all aligned in similar directions; this is a constraint on fiducials placement.