AFL.automation.vision.RGBCamera#

Classes

Driver(name[, defaults, overrides, ...])

NeutronSampleCell([overrides])

Describe the circular optical region of a neutron sample cell.

RGBCamera([overrides, sample_cell])

Driver for capturing RGB images and computing average RGB values.

SampleCell([overrides])

Base interface for sample-cell image geometry.

class AFL.automation.vision.RGBCamera.RGBCamera(overrides=None, sample_cell=None)[source]#

Driver for capturing RGB images and computing average RGB values.

This driver interfaces with a USB camera to capture images and extract the average RGB values along with image metadata.

defaults = {'background': 'background.npz', 'background_capture_on_init': True, 'background_threshold': 25, 'camera_index': 0, 'camera_properties': {'CAP_PROP_AUTOFOCUS': 1, 'CAP_PROP_AUTO_EXPOSURE': 0.75, 'CAP_PROP_BUFFERSIZE': 1}, 'camera_warmup_delay': 2.0, 'save_path': '/home/afl642/rgb_images/', 'show_background_pipeline': False, 'subtract_background': True}#
__init__(overrides=None, sample_cell=None)[source]#

Initialize RGBCamera driver.

Parameters:
  • overrides (dict, optional) – Configuration overrides for PersistentConfig.

  • sample_cell (SampleCell, optional) – Geometry and image-processing strategy. Defaults to a neutron sample cell configured for the legacy RGB-camera crop.

open()[source]#

Open the configured OpenCV camera and retain its capture handle.

close()[source]#

Release the OpenCV camera handle so another process can use it.

refresh_background(**kwargs)[source]#

Capture and persist a new cropped background reference image.

The local archive is available immediately at AFL_HOME/RGBCamera/background.npz. When this queued result is written to Tiled, post_tiled_finalize() switches self.bkg to the resulting Tiled entry ID.

post_tiled_finalize(task, tiled_entry_id)[source]#

Use the persisted Tiled background after a successful refresh.

capture_rgb(name='', plotting=False, subtract_background=False, show_background_pipeline=False, **kwargs)[source]#

Capture an image and compute average RGB values.

Parameters:
  • name (str, optional) – Name/identifier for the measurement.

  • plotting (bool, optional) – If True, save diagnostic plots of the captured image.

  • subtract_background (bool, optional) – If True, use the stored background reference to compute the average RGB.

  • show_background_pipeline (bool, optional) – If True, display the background subtraction diagnostic plot.

  • **kwargs (dict) – Additional arguments passed to image collection.

Returns:

Dataset with average RGB values, image, and metadata.

Return type:

xarray.Dataset