science_jubilee.tools.WebCamera#

Module Contents#

Classes#

Camera

A class representation of a Raspberry Pi camera server client.

class science_jubilee.tools.WebCamera.Camera(index, name, ip_address, port, video_endpoint, still_endpoint, image_folder, focus_height, light: bool = False, light_pin: int = None)#

Bases: science_jubilee.tools.Tool.Tool

A class representation of a Raspberry Pi camera server client.

classmethod from_config(index, name, config_file: str, path: str = os.path.join(os.path.dirname(__file__), 'configs'))#

Initialize the pipette object from a config file

Parameters:
  • index (int) – The tool index of the pipette on the machine

  • name (str) – The name associated with the tool (e.g. ‘WebCamera’)

  • config_file (str) – The name of the config file containing the tool parameters

  • path (str, optional) – The path to the labware configuration .json files for the labware, defaults to the ‘labware_definition/’ in the science_jubilee/labware directory.

Returns:

the initialized Camera object

Return type:

Camera object

_capture_image(timeout=30)#

Capture image from raspberry pi and write to file

Parameters:

timeout (int, optional) – the timeout for the http request, defaults to 10

Returns:

the image as a bstring

Return type:

bytes

capture_image(location: science_jubilee.labware.Labware.Well | Tuple, light: bool = False, light_intensity: int = 0, timeout=30)#

Capture an image from the WebCamera at the specified location

Parameters:
  • location (Union[Well, Tuple]) – the location of the well to capture an image of

  • light (bool, optional) – Option to turn on a ring light before taking the image, defaults to False

  • light_intensity (int, optional) – Intensity of the led rign light, defaults to 0

Returns:

the image as an bstring

Return type:

bytes

video_feed()#

Deploys a video feed at the url specified in the config file

decode_image(image_bin)#

Decode a bstring image into an np.array

Parameters:

image_bin (bytes) – the image as a bstring

Returns:

the image as an np.array

Return type:

np.array

process_image(image_bin, radius=50)#

Externally callable function to run processing pipeline

Parameters:
  • image_bin (bytes) – the image as a bstring

  • radius (int, optional) – the radius (in pixels) of the circular mask, defaults to 50

Returns:

the average rgb values of the masked image

Return type:

list

_mask_image(image, radius=50)#

Apply a circular mask to an image

Parameters:
  • image (np.array) – the image object

  • radius (int, optional) – the size (in pixels) of the circular mask, defaults to 50

Returns:

the masked image

Return type:

np.array

_get_rgb_avg(image)#

Extract the average rgb values from an image

Parameters:

image (np.array) – the image object

Returns:

the average rgb values in a list [R,G,B]

Return type:

list

view_image(image_bin, masked=False, radius=50)#

Show the image in a matplotlib window

Parameters:
  • image_bin (bytes) – the image as a bstring

  • masked (bool, optional) – Wether to mask the image or not, defaults to False

  • radius (int, optional) – the size (in pixel) of the circular mask toapply to the image , defaults to 50