Frame

The frame buffer collects data into a Frame:

class obi.macros.frame_buffer.Frame(x_res, y_res)[source]

A Frame represents a 2D array of pixels.

Properties:

canvas: 2D numpy.ndarray of np.uint16 representing an image

Parameters:
  • x_res (int) – Number of pixels in X

  • y_res (int) – Number of pixels in Y

classmethod from_DAC_ranges(x_range, y_range)[source]

Generate a frame from two instances of :class:DACCodeRange

Parameters:
Returns:

Frame

property pixels: int[source]

Number of pixels in the frame

property np_shape[source]

Returns: tuple: Shape of the underlying array in the form (y, x)

fill(pixels)[source]

Fill the entire contents of the Frame at once.

Parameters:

pixels (array) – 1D array of pixel data

Raises:

ValueError – If the number of pixels isn’t equal to the Frame’s pixels

fill_lines(pixels)[source]

Fill a partial section of the frame with data. Only whole lines will be accepted.

Parameters:

pixels (array) – 1D array of pixel data

as_uint16()[source]

Get underlying frame data as an array of type np.uint16

Return type:

ndarray

as_uint8()[source]

Get underlying frame data as an array of type np.uint8

Return type:

ndarray

Frame Buffer

class obi.macros.frame_buffer.FrameBuffer(conn)[source]

The Frame Buffer executes raster scan commands and stores the results in a :class:Frame. It is suitable for a live graphical display, or for headless scripted capture.

Parameters:

conn (Connection) – A connection to an OBI device, via a Glasgow device

abort_scan()[source]

Stop the scan without completing a frame

property is_aborted[source]

True if all of the following are true: - An abort event exists - The abort event has already been set If true, also clears the existing abort event by setting self.abort to None.

Returns:

True if scan was previously aborted mid-frame

async capture_frame(*, x_range, y_range, dwell_time, **kwargs)[source]

Simplest method to capture a single frame. Unlike frame capture methods that are used with the GUI, no partially filled frames are returned.

Parameters:
  • x_range (DACCodeRange) – X range for raster scan

  • y_range (DACCodeRange) – Y range for raster scan

  • dwell_time (int) – Pixel dwell time

Returns:

Frame

async capture_frame_roi(*, x_res, y_res, x_start, x_count, y_start, y_count, **kwargs)[source]

Scan and capture data into a selected region of a frame

Parameters:
  • x_res (int) – X resolution of full frame

  • y_res (int) – Y resolution of full frame

  • x_start (int) – X coordinate of top left corner of ROI

  • x_count (int) – Number of steps in X in ROI

  • y_start (int) – Y coordinate of top left corner of ROI

  • y_count (int) – Number of steps in Y in ROI

Yields:

Frame – Full frame with new data filled into region of interest. A Frame object is yielded each time new pixels are added.

async capture_full_frame(*, x_res, y_res, **kwargs)[source]

Scan and capture data into a frame that spans the entire DAC range.

Parameters:
  • x_res (int) – Number of pixels in X

  • y_res (int) – Number of pixels in Y

Yields:

Frame – A Frame object is yielded each time new pixels are added