science_jubilee.tools.Camera ============================ .. py:module:: science_jubilee.tools.Camera Classes ------- .. autoapisummary:: science_jubilee.tools.Camera.Well science_jubilee.tools.Camera.Tool science_jubilee.tools.Camera.Camera Functions --------- .. autoapisummary:: science_jubilee.tools.Camera.requires_active_tool Module Contents --------------- .. py:class:: Well A class representing a well of a labware. Each Well is associated with a specific name, depth, total liquid volume, shape, diameter, x, y, and z dimension, y-dimension, as well as its coordinates and any applied offset :return: A :class:`Well` object with various information about the geometry of the well and its position in the labware :rtype: :class:`Well` .. py:attribute:: name :type: str .. py:attribute:: depth :type: float .. py:attribute:: totalLiquidVolume :type: float .. py:attribute:: shape :type: str .. py:attribute:: diameter :type: float :value: None .. py:attribute:: xDimension :type: float :value: None .. py:attribute:: yDimension :type: float :value: None .. py:attribute:: x :type: float .. py:attribute:: y :type: float .. py:attribute:: z :type: float .. py:attribute:: offset :type: Tuple[float] :value: None .. py:attribute:: slot :type: int :value: None .. py:attribute:: has_tip :type: bool :value: False .. py:attribute:: clean_tip :type: bool :value: False .. py:attribute:: labware_name :type: str :value: None .. py:property:: x Offsets the x-position of the each well with respect to the deck-slot coordinates :return: The x-coordinate of the well :rtype: float .. py:property:: y Offsets the y-position of the each well with respect to the deck-slot coordinates :return: The y-coordinate of the well :rtype: float .. py:property:: z Offsets the z-position of each well with respect to the deck-slot coordinates :return: The z-coordinate of the well :rtype: float .. py:method:: apply_offset(offset: Tuple[float]) Allows the user to offset the coordinates of the well with respect to the deck-slot coordinates :param offset: A tuple of floats with the new offset of the well :type offset: Tuple[float] .. py:property:: top_ Defines the top-most point of the well :return: The z-coordinate of the top of the well :rtype: float .. py:property:: bottom_ Defines the bottom-most point of the well :return: The z-coordinate of the bottom of the well :rtype: float .. py:method:: bottom(z: float, check=False) Allows the user to dinamically indicate a new Z location relative to the bottom of the well. :param z: the distance in mm to offset the coordinates from the bottom of the well. Should be + :type z: float :param check: the 'z' parameters can either be + or -. If negative, an assert error is raised to avoid collision with the labware. However, there might be instances of custom labware where the bottom of the well is purposely set as higher during the generation of its config .json file., defaults to False :type check: bool, optional :return: A :class:`Location` which contains information about the new coordinates generated and the :class:`Well` object :rtype: :class:`Location` .. py:method:: top(z: float) Allows the user to dinamically indicate a new Z location relative to the top of the well. :param z: the distance in mm to offset the coordinates from the top of the well.Can be either + or - :type z: float :return: A :class:`Location` which contains information about the new coordinates generated and the :class:`Well` object. :rtype: :class:`Location` .. py:method:: __repr__() Displayed representation of a :class:`Well` object indicating its name and its coordinates :return: A string representation of the name and coordinates of a well :rtype: str .. py:method:: set_has_tip(value: bool) Set the value of the `has_tip` attribute. :param value: The new value for the `has_tip` attribute :type value: bool .. py:method:: set_clean_tip(value: bool) Returns the value of the `clean_tip` attribute. :param value: The new value for the `clean_tip` attribute :type value: bool .. py:class:: Tool(index, name, **kwargs) .. py:method:: post_load() Run any code after tool has been associated with the machine. .. py:function:: requires_active_tool(func) Decorator to ensure that a tool cannot complete an action unless it is the current active tool. .. py:class:: Camera(index, name) Bases: :py:obj:`science_jubilee.tools.Tool.Tool` A class representation of a Raspberry Pi camera. :param Tool: The base tool class :type Tool: class:`Tool` .. py:method:: load_coefficients(path) Loads camera matrix and distortion coefficients. :param path: Path to your camera calibration file :type path: str :return: A list containing your camera matrix (index 0) and distortion matrix (index 1) :rtype: list .. py:method:: get_camera_indices() Returns valid camera indices for use with OpenCV :return: A list of valid camera indices :rtype: list .. py:method:: get_frame(resolution=[1200, 1200], uvc=False) Take a picture and return the image. Compensates for lens distortion using camera calibration file. :param resolution: Camera resolution, defaults to [1200, 1200] :type resolution: list, optional :param uvc: True if the camera is a USB video class (UVC) camera for programmatically setting focus, defaults to False :type uvc: bool, optional :return: The captured frame :rtype: ndarray .. py:method:: show_frame(frame, grid=False, save=False, save_path='fig.png') Show a captured frame using matplotlib. :param frame: The captured frame to show :type frame: ndarray :param grid: Show grid lines, defaults to False :type grid: bool, optional :param save: Save to file, defaults to False :type save: bool, optional :param save_path: File path to save image, defaults to "fig.png" :type save_path: str, optional .. py:method:: get_show_frame() Get and show a frame. .. py:method:: video_stream(camera_index=0) Start a video stream from the camera. :param camera_index: The camera index, defaults to 0 :type camera_index: int, optional .. py:method:: image_wells(resolution=[1200, 1200], uvc=False, wells: science_jubilee.labware.Labware.Well = None) Move to a number of wells to take and show images. :param resolution: Camera resolution, defaults to [1200, 1200] :type resolution: list, optional :param uvc: True if the camera is a USB video class (UVC) camera for programmatically setting focus, defaults to False :type uvc: bool, optional :param wells: A list of wells to image, defaults to None :type wells: :class:`Well`, optional .. py:method:: get_well_image(resolution=[1200, 1200], uvc=False, well: science_jubilee.labware.Labware.Well = None) Move to a single well to take a picture and return the frame. :param resolution: Camera resolution, defaults to [1200, 1200] :type resolution: list, optional :param uvc: True if the camera is a USB video class (UVC) camera for programmatically setting focus, defaults to False :type uvc: bool, optional :param well: The well to image, defaults to None :type well: :class:`Well`, optional :return: The captured frame :rtype: ndarray .. py:method:: _get_xyz(well: science_jubilee.labware.Labware.Well = None, location: Tuple[float] = None) :staticmethod: Get the (x,y,z) position of a well. :param well: The well to fetch position of, defaults to None :type well: :class:`Well`, optional :param location: Directly specify an (x,y,z) location, defaults to None :type location: Tuple[float], optional :raises ValueError: Must specify either a well or a location :return: The well location :rtype: Tuple[float, float, float] .. py:method:: _get_top_bottom(well: science_jubilee.labware.Labware.Well = None) :staticmethod: Get the top and bottom heights of a well. :param well: The well to fetch position of, defaults to None :type well: Well, optional :return: The z-height of the top and bottom of the well :rtype: Tuple[float, float]