opencsp.app.sofast.lib.Fringes
Representation sinusoidal pattern (Fringe) used in a Sofast measurement.
- class opencsp.app.sofast.lib.Fringes.Fringes(periods_x: list, periods_y: list)
Bases:
objectClass that handles calculating the sinusoidal fringes used in a SOFAST calculation. A fringe is an image whos intensity varies in either x or y according to a sinusoid.
- classmethod from_num_periods(fringe_periods_x=4, fringe_periods_y=4) Fringes
Creates fringes to be displayed during run_measurement().
The fringes are displayed as sinusoidal grayscale images. A value of 1 means that only a single large sinusoidal will be used. A higher value will display more images with a faster sinusoidal. Therefore, a higher value will result in finer slope resolution, up to the resolving power of the optical setup.
Note that a different number of periods may be required for x and for y, if the x and y resolutions differ enough.
Params:
- fringe_periods_x: int, optional
Granularity for fringe periods in the x direction. Defaults to 4.
- fringe_periods_y: int, optional
Granularity for fringe periods in the y direction. Defaults to 4.
- returns:
The fringes object, to be used with run_measurement().
- rtype:
fringes
- get_frames(x: int, y: int, dtype: str, range_: list[float, float]) ndarray
Returns 3D ndarray of scaled, monochrome fringe images.
- Parameters:
x/y (int) – Size of image in x/y.
dtype (str) – Data type accepted by image display.
range (list[float, float]) – The range of the output sinusoids. [min, max].
- Returns:
images – 3D numpy array of scaled images.
- Return type:
ndarray
- static get_sinusoids(length: int, periods: list[float], phase_shifts: int) list[ndarray]
Creates list of phase shifted sinusoids for given periods ranging from -1 to 1.
- Parameters:
length (int) – Number of samples to generate over width.
periods (list[float, ...]) – List of periods to make sinusoids for, fractional widths.
phase_shifts (int) – Number of phase shifts.
- Returns:
sinusoids – List of 1d nparrays. Float, magnitude ranges from -1 to 1
- Return type:
list[np.ndarray, …]
opencsp.app.sofast.lib.ImageCalibrationAbstract
- class opencsp.app.sofast.lib.ImageCalibrationAbstract.ImageCalibrationAbstract(camera_values: ndarray, display_values: ndarray)
Bases:
HDF5_IO_Abstract,AbstractPlotHandler,ABC- abstract apply_to_images(measurement) ndarray
Performs camera-projector brightness values calibration.
- Parameters:
fringe_images (ndarray) – Measurement fringe images.
- Returns:
Calibrated fringe images, float.
- Return type:
ndarray
- calculate_min_display_camera_values(derivative_thresh: float = 0.4) tuple[float, float]
Calculates the minimum display and camera brightness values to be used in a valid calibration. Values lower than these values are too close to the noise floor of the camera.
- Parameters:
derivative_thresh (float, optional) – Threshold of derivative to determine valid calibration range. The default is 0.4.
- Returns:
(display_min_value, camera_min_value).
- Return type:
tuple[float, float]
- classmethod from_data(images_cal: ndarray, display_values: ndarray, mask: ndarray | None = None, num_samps: int = 1000) ImageCalibrationAbstract
Calculates camera values from calibration images. Returns ImageCalibration object.
- Parameters:
images_cal (ndarray) – Shape (n, m, N) ndarray. Shape of image = (n, m). N = number of calibration images.
display_values (ndarray) – 1D ndarray of display values.
mask ([ndarray | None], optional) – Shape (n, m) boolean ndarray. Mask defining which pixels to consider. The default is None.
num_samps (int, optional) – Calculate using num_samps of the brightest pixels. The default is 1000.
- Return type:
- static get_cal_options() dict[str, type[ImageCalibrationAbstract]]
Available calibration objects that can be instantiated with load_from_hdf_guess_type()
- abstract static get_calibration_name() str
The name of the calibration class type (for saving/loading data)
- classmethod load_from_hdf(file: str, prefix: str = '') ImageCalibrationAbstract
Loads from HDF5 file
- Parameters:
file (string) – HDF5 file to load
- static load_from_hdf_guess_type(hdf5_file_path_name_ext: str, prefix: str = '') ImageCalibrationAbstract
Loads saved results of a projector-camera intensity calibration, returning a calibration instance whose type is based on information stored in the given file.
Raises:
- KeyError:
If the necessary typing information isn’t available in the given file
- ValueError:
If the type of the calibration instance in the given file is unknown
- plot_gray_levels() None
Shows plot of gray levels calibration data. When the close() method of this instance is called (or this instance is destructed), the plot will be closed automatically.
- save_to_hdf(file: str, prefix: str = '') None
Saves to HDF file
- Parameters:
file (string) – HDF5 file to save
opencsp.app.sofast.lib.ImageCalibrationGlobal
- class opencsp.app.sofast.lib.ImageCalibrationGlobal.ImageCalibrationGlobal(camera_values: ndarray, display_values: ndarray)
Bases:
ImageCalibrationAbstract- apply_to_images(measurement: MeasurementSofastFringe) ndarray
Performs camera-projector brightness values calibration by applying the camera-display response curve to all pixels equally.
- Parameters:
fringe_images (ndarray) – Measurement fringe images.
- Returns:
Calibrated fringe images, float.
- Return type:
ndarray
- static get_calibration_name() str
The name of this calibration class type
opencsp.app.sofast.lib.ImageCalibrationScaling
- class opencsp.app.sofast.lib.ImageCalibrationScaling.ImageCalibrationScaling(camera_values: ndarray, display_values: ndarray)
Bases:
ImageCalibrationAbstractClass that handles performing a pixel-wise calibration that ‘scales’ each pixel in a Sofast image according to a camera-projector-response calibration curve.
- apply_to_images(measurement: MeasurementSofastFringe) ndarray
Performs camera-projector brightness values calibration in two steps.
Using captured mask images, pixel values are scaled to match their expected min/max values given the calibration response curve.
The camera to display digital number (DN) response interpolation is applied to all pixel values.
- Parameters:
measurement (Measurement) – Measurement object to apply calibration to.
- Returns:
Calibrated fringe images, float.
- Return type:
ndarray
- static get_calibration_name() str
The name of this calibration class type
opencsp.app.sofast.lib.MeasurementSofastFixed
- class opencsp.app.sofast.lib.MeasurementSofastFixed.MeasurementSofastFixed(image: ndarray, dist_optic_screen_measure: DistanceOpticScreen, origin: Vxy, date: datetime | None = None, name: str = '')
Bases:
AbstractMeasurementSofastFixed pattern measuremnt class. Stores measurement data. Can save and load to HDF file format.
- classmethod load_from_hdf(file: str, prefix: str = '') MeasurementSofastFixed
Loads data from given file. Assumes data is stored as: PREFIX + MeasurementSofastFringe/Field_1
- Parameters:
file (string) – HDF file to load
prefix (str, optional) – Prefix to append to folder path within HDF file (folders must be separated by “/”). Default is empty string ‘’.
- save_to_hdf(file: str, prefix: str = '') None
Saves data to given file. Data is stored as: PREFIX + MeasurementSofastFringe/Field_1
- Parameters:
file (string) – HDF file to save
prefix (str, optional) – Prefix to append to folder path within HDF file (folders must be separated by “/”). Default is empty string ‘’.
opencsp.app.sofast.lib.MeasurementSofastFringe
Measurement class for SofastFringe
- class opencsp.app.sofast.lib.MeasurementSofastFringe.MeasurementSofastFringe(mask_images: ndarray, fringe_images: ndarray, fringe_periods_x: ndarray, fringe_periods_y: ndarray, dist_optic_screen_measure: DistanceOpticScreen, date: datetime, name: str = '')
Bases:
AbstractMeasurementSofastSofastFringe measurement data class that contains captured images and metadata about the measurement.
- calibrate_fringe_images(calibration: ImageCalibrationAbstract, **kwargs) None
Performs brightness level calibration on the raw captured fringes.
- Parameters:
calibration (ImageCalibrationAbstract) – Image Calibration object.
**kwargs – Other keyword arguments to pass into ImageCalibration object “apply_to_images” method.
- property fringe_images_calibrated: ndarray
Returns calibrated fringes
- property fringe_images_x: ndarray
Returns raw x-only fringes
- property fringe_images_x_calibrated: ndarray
Returns calibrated x-only fringes
- property fringe_images_y: ndarray
Returns raw y-only fringes
- property fringe_images_y_calibrated: ndarray
Returns calibrated y-only fringes
- classmethod load_from_hdf(file: str, prefix: str = '') MeasurementSofastFringe
Loads data from given file. Assumes data is stored as: PREFIX + MeasurementSofastFringe/Field_1
- Parameters:
file (string) – HDF file to load
prefix (str, optional) – Prefix to append to folder path within HDF file (folders must be separated by “/”). Default is empty string ‘’.
- save_to_hdf(file: str, prefix: str = '') None
Saves data to given file. Data is stored as: PREFIX + MeasurementSofastFringe/Field_1
- Parameters:
file (string) – HDF file to save
prefix (str, optional) – Prefix to append to folder path within HDF file (folders must be separated by “/”). Default is empty string ‘’.
opencsp.app.sofast.lib.ParamsSofastFringe
Parameter dataclass for SofastFringe
- class opencsp.app.sofast.lib.ParamsSofastFringe.ParamsSofastFringe(mask: ~opencsp.app.sofast.lib.ParamsMaskCalculation.ParamsMaskCalculation = <factory>, geometry: ~opencsp.app.sofast.lib.ParamsOpticGeometry.ParamsOpticGeometry = <factory>, debug_slope_solver: ~opencsp.common.lib.deflectometry.SlopeSolverDataDebug.SlopeSolverDataDebug = <factory>, debug_geometry: ~opencsp.app.sofast.lib.DebugOpticsGeometry.DebugOpticsGeometry = <factory>)
Bases:
HDF5_IO_AbstractParameters for SofastFringe processing calculation
- debug_geometry: DebugOpticsGeometry
Debug options for geometry processing
- debug_slope_solver: SlopeSolverDataDebug
Debug options for slope solving
- geometry: ParamsOpticGeometry
Parameters for calculating optic geometry
- classmethod load_from_hdf(file: str, prefix: str = '')
Loads data from given file. Assumes data is stored as: PREFIX + ParamsSofastFringe/Field_1
- Parameters:
file (str) – HDF file to load from
prefix (str, optional) – Prefix to append to folder path within HDF file (folders must be separated by “/”). Default is empty string ‘’.
- mask: ParamsMaskCalculation
Parameters for calculating optic mask
- save_to_hdf(file: str, prefix: str = '')
Saves data to given HDF5 file. Data is stored in PREFIX + ParamsSofastFringe/…
- Parameters:
file (str) – HDF file to save to
prefix (str) – Prefix to append to folder path within HDF file (folders must be separated by “/”)
opencsp.app.sofast.lib.ParamsSofastFixed
Parameters class for SofastFixed
- class opencsp.app.sofast.lib.ParamsSofastFixed.ParamsSofastFixed(blob_search_thresh: float = 5.0, search_perp_axis_ratio: float = 3.0, mask: ~opencsp.app.sofast.lib.ParamsMaskCalculation.ParamsMaskCalculation = <factory>, geometry: ~opencsp.app.sofast.lib.ParamsOpticGeometry.ParamsOpticGeometry = <factory>, debug_slope_solver: ~opencsp.common.lib.deflectometry.SlopeSolverDataDebug.SlopeSolverDataDebug = <factory>, debug_geometry: ~opencsp.app.sofast.lib.DebugOpticsGeometry.DebugOpticsGeometry = <factory>)
Bases:
HDF5_IO_AbstractParameters for SofastFixed processing calculation
- blob_search_thresh: float = 5.0
Pixels, search radius when finding next dot
- debug_geometry: DebugOpticsGeometry
Debug options for geometry processing
- debug_slope_solver: SlopeSolverDataDebug
Debug options for slope solving
- geometry: ParamsOpticGeometry
Parameters to use when processing geometry of facet
- classmethod load_from_hdf(file: str, prefix: str = '')
Loads data from given file. Assumes data is stored as: PREFIX + ParamsSofastFixed/Field_1
- Parameters:
file (str) – HDF file to load from
prefix (str, optional) – Prefix to append to folder path within HDF file (folders must be separated by “/”). Default is empty string ‘’.
- mask: ParamsMaskCalculation
Parameters for calculating optic mask
- save_to_hdf(file: str, prefix: str = '')
Saves data to given HDF5 file. Data is stored in PREFIX + ParamsSofastFixed/…
- Parameters:
file (str) – HDF file to save to
prefix (str) – Prefix to append to folder path within HDF file (folders must be separated by “/”)
- search_perp_axis_ratio: float = 3.0
Defines search region when searching for next dot. Ratio of length along search direction to perpendicular distance. Larger value equals narrower search region.
opencsp.app.sofast.lib.SofastInterface
Sofast Interface Module for Optical Measurement Processing.
This module provides the SofastInterface class, which facilitates the configuration and execution of optical measurements using the SOFAST framework. It includes functionality for initializing measurement systems, processing fringe and fixed measurements, and handling user interactions. The module also supports saving and loading calibration data, displaying camera images, and managing the overall workflow of optical measurements.
Usage:
To use this module, create an instance of the SofastInterface class with an image acquisition object, and then call the appropriate methods to run measurements and process data. See /example/ for more information.
TODO:
Refactor so that common code is separate from end-of-file input/execution block, move this to common.
Make this a “kitchen sink” file, which includes all aspects:
Data collection:
Fringe measurement
Fixed measurement with projector
Fixed measurement with printed target in ambient lght
Data analysis – finding the best-fit instance of the class of shapes.
Fitting to a desired reference optical shape. (Make this an enhancement issue added to SOFAST. Then, another file?)
Plotting/ray tracing
(Suggest puttting calibration in another file.)
This file contains 1 and 2.
- class opencsp.app.sofast.lib.SofastInterface.SofastCommonProcessData(facet_definition: DefinitionFacet, camera: Camera, spatial_orientation: SpatialOrientation)
Bases:
objectData class holding data common to processing captured Sofast Fixed or Fringe measurements
- facet_definition: DefinitionFacet
The definition of the optical facet being measured.
- spatial_orientation: SpatialOrientation
The spatial orientation of the measurement setup.
- class opencsp.app.sofast.lib.SofastInterface.SofastCommonRunData(measure_point_optic: Vxyz, dist_optic_screen: float, name_optic: str)
Bases:
objectData class holding data required to run Sofast Fixed and Fringe
- dist_optic_screen: float
The distance from the optic to the screen, in meters.
- name_optic: str
A descriptive name for the optical system.
- class opencsp.app.sofast.lib.SofastInterface.SofastFixedProcessData(fixed_pattern_dot_locs: DotLocationsFixedPattern, surface_2d: Surface2DParabolic)
Bases:
objectData class holding data required to process captured Sofast Fixed measurements
- fixed_pattern_dot_locs: DotLocationsFixedPattern
The locations of fixed pattern dots used in measurements.
- surface_2d: Surface2DParabolic
The 2D surface model used for processing fixed data.
- class opencsp.app.sofast.lib.SofastInterface.SofastFixedRunData(origin: Vxy, xy_known: tuple[int, int] = (0, 0))
Bases:
objectData class holding data required to run Sofast Fixed
- pattern_spacing = 6
Fixed pattern dot spacing between edges of neighboring dots, pixels.
- pattern_width = 3
Fixed pattern dot width, pixels
- xy_known: tuple[int, int] = (0, 0)
The xy index of a known dot location seen by the camera
- class opencsp.app.sofast.lib.SofastInterface.SofastFringeProcessData(display_shape: DisplayShape, surface_2d: Surface2DParabolic)
Bases:
objectData class holding data required to process captured Sofast Fringe measurements
- display_shape: DisplayShape
The display shape used in the fringe measurement.
- surface_2d: Surface2DParabolic
The 2D surface model used for processing fringe data.
- class opencsp.app.sofast.lib.SofastInterface.SofastInterface(image_acquisition: ImageAcquisitionAbstract)
Bases:
objectInterface for managing SOFAST optical measurement systems.
The SofastInterface class provides methods to initialize and run measurements using the SOFAST framework. It manages the configuration of fringe and fixed measurement systems, processes measurement data, and handles user interactions. The class also supports saving and loading calibration data and displaying camera images.
- Parameters:
image_acquisition (ImageAcquisitionAbstract) – Object responsible for acquiring images from the camera.
- property file_timestamp: str
Returns current run timestamp in string format
- func_gray_levels_cal() None
Runs gray level calibration sequence
- func_load_last_sofast_fringe_image_cal() None
Loads last ImageCalibration object
- func_process_sofast_fixed_data() None
Process Sofast Fixed data
- func_process_sofast_fringe_data() None
Processes Sofast Fringe data
- func_run_fixed_measurement() None
Runs Sofast Fixed measurement
- func_run_fringe_measurement() None
Runs sofast fringe measurement
- func_save_measurement_fixed() None
Save fixed measurement files
- func_save_measurement_fringe() None
Saves measurement to HDF file
- func_show_crosshairs_fringe() None
Shows crosshairs and run next in Sofast fringe queue after a 0.2s wait
- initialize_sofast_fixed() None
Initializes sofast fixed system
- initialize_sofast_fringe(fringes: Fringes) None
Initializes sofast fringe system
- Parameters:
fringes (Fringes) – Input fringe object to initialize Sofast Fringe system
- run_cli() None
Runs command line Sofast
- show_cam_image() None
Shows a camera image
- show_live_view() None
Shows live view window
opencsp.app.sofast.lib.SystemSofastFringe
- class opencsp.app.sofast.lib.SystemSofastFringe.SystemSofastFringe(image_acquisition: ImageAcquisitionAbstract | list[ImageAcquisitionAbstract] | None = None)
Bases:
objectClass for controlling/displaying Sofast patterns and capturing images
- property calibration
this is not a setter, use set_calibration() instead
- Type:
Returns ImageCalibration object. Note
- capture_fringe_images(run_next: Callable | None = None) None
Captures fringe images only. When finished, “run_next” is called. Images are stored in “_fringe_images_captured”
- Parameters:
run_next (Callable) – Function that is called after all images are captured. The default is self.close_all(). TODO is this still the default?
- capture_mask_and_fringe_images(run_next: Callable | None = None) None
Captures mask frames, then captures fringe images.
- Mask and fringe images are stored in:
“_mask_images_captured” “_fringe_images_captured”
- Parameters:
run_next (Callable) – Function that is called after all images are captured. The default is self.close_all(). TODO is this still the default?
- capture_mask_images(run_next: Callable | None = None) None
Captures mask images only. When finished, “run_next” is called. Images are stored in “_mask_images_captured”
- Parameters:
run_next (Callable, optional) – Function that is called after all images are captured. The default is self.close_all(). TODO is this still the default?
- check_saturation(image: ndarray, camera_max_int: int, thresh: float = 0.005) None
Checks if input image is saturated. Gives warning if image is saturated above given threshold.
- Parameters:
image (ndarray) – Input image.
camera_max_int (int) – Saturation value of camera.
thresh (float, optional) – Fraction of image saturation that is acceptable. The default is 0.5%.
- close_all()
Closes all windows
- create_fringe_images_from_image_calibration()
Once the system loads a new calibration object, a new min_display_value and RGB fringe images must be made
- get_calibration_images() list[ndarray]
Returns list of sets of calibration images as 3D ndarrays.
- Returns:
images – List of shape (N, M, n) arrays.
- Return type:
list[ndarray, …]
- get_measurements(v_measure_point: Vxyz, dist_optic_screen: float, name: str) list[MeasurementSofastFringe]
Returns measurement object once mask and fringe images have been captured.
- Parameters:
v_measure_point (Vxyz) – Location of measure point in optic coordinates.
dist_optic_screen (float) – Distance from mirror to center of screen during measurement.
name (str) – Name/serial number of measurement.
- Returns:
Output list of measurement objects.
- Return type:
list[Measurement]
- property image_acquisitions: list[ImageAcquisitionAbstract]
Loaded image acquisition instances
- reset_all_measurement_data() None
Resets all attributes related to capturing measurements
- run() None
Instantiates the system by starting the mainloop of the ImageProjection object.
- run_display_camera_response_calibration(res: int = 10, run_next: Callable | None = None) None
Calculates camera-projector response data. Data is saved in _calibration_display_values and _calibration_images_captured.
- Parameters:
res (int, optional) – Digital number step size when stepping from 0 to “projector_max_int”.
run_next (Callable) – Process to run after calibration is performed.
- run_gray_levels_cal(calibration_class: type[ImageCalibrationAbstract], calibration_hdf5_path_name_ext: str | None = None, on_capturing: Callable | None = None, on_captured: Callable | None = None, on_processing: Callable | None = None, on_processed: Callable | None = None) None
Runs the projector-camera intensity calibration and stores the results in self._calibration_images_captured and self._calibration.
Params:
- calibration_classtype[ImageCalibrationAbstract]:
The type of calibration to use.
- calibration_hdf5_path_name_extstr, optional
The pathname of the output HDF5 file, does not save if None. Default is None
- on_capturingCallable, optional
The callback to execute when capturing is about to start. Default is None
- on_capturedCallable, optional
The callback to execute when capturing has finished. Default is None
- on_processingCallable, optional
The callback to execute when processing is about to start. Default is None
- on_processedCallable, optional
The callback to execute when processing has finished. At the point this callback is being called the calibration attribute will be set. Default is None
- run_measurement(on_done: Callable | None = None) None
Runs data collection with the given fringes.
Once the data has been captured, the images will be available from this instance. Similarly, the data can then be processed, such as with get_measurements().
Params
- on_done: Callable
The function to call when capturing fringe images has finished.
- raises RuntimeError::
Calibration hasn’t been set, or fringes haven’t been set
- run_next_in_queue() None
Runs the next funtion in the queue and removes from queue
- set_calibration(calibration: ImageCalibrationAbstract) None
Loads calibration object and creates RGB fringe images to display.
- Parameters:
calibration (ImageCalibrationAbstract) – The image calibration object to use during fringe image generation
- set_fringes(fringes: Fringes) None
Sets the fringes object in the class
- Parameters:
fringes (Fringes) – Fringe object to set to System
- set_queue(funcs: list[Callable]) None
Sets the queue to given list of Callables
opencsp.app.sofast.lib.PatternSofastFixed
- class opencsp.app.sofast.lib.PatternSofastFixed.PatternSofastFixed(size_x: int, size_y: int, width_pattern: int, spacing_pattern: int)
Bases:
objectClass that holds parameters for displaying a Fixed Pattern for use in fixed pattern deflectometry.
- get_image(dtype: str, max_int: int, dot_shape: Literal['circle', 'square'] = 'circle') ndarray
Creates a NxMx3 fixed pattern image
- Parameters:
dtype (str) – Output datatype of image
max_int (int) – Integer value corresponding to “white.” Zero corresponds to black.
dot_shape (str) – ‘circle’ or ‘square’
- Returns:
(size_y, size_x, 3) ndarray
- Return type:
ndarray
opencsp.app.sofast.lib.SofastConfiguration
Class that analyzes the configuration of a Sofast run. This includes: - The physical system layout - Statistics from a Sofast measurement
- class opencsp.app.sofast.lib.SofastConfiguration.SofastConfiguration
Bases:
objectClass for analyzing the configuration of a Sofast setup/measurement.
- get_measurement_stats() list[dict]
Returns measurement statistics dictionary for each facet in Sofast calculation
- Returns:
list of dictionaries for each facet in the ProcessSofast object with following fields
- delta_x_sample_points_average
- delta_y_sample_average
- number_samples
- focal_lengths_parabolic_xy
- load_sofast_object(process_sofast: ProcessSofastFringe | ProcessSofastFixed)
Loads ProcessSofast object (Fixed or Fringe) for further analysis
- Parameters:
process_sofast (ProcessSofastFringe | ProcessSofastFixed) – ProcessSofast object
- visualize_setup(length_z_axis_cam: float = 8, axes_length: float = 2, min_axis_length_screen: float = 2, ax: Axes | None = None, v_screen_object_screen: Vxyz | None = None, r_object_screen: Rotation | None = None) None
Draws the given SOFAST setup components on a 3d axis.
- Parameters:
length_z_axis_cam (float, optional) – Length of camera z axis to draw (m), by default 8
axes_length (float, optional) – Length of all other axes to draw (m), by default 2
min_axis_length_screen (float, optional) – Minimum length of axes to draw (m), by default 2
ax (plt.Axes | None, optional) – 3d matplotlib axes, if None, creates new axes, by default None
v_screen_object_screen (Vxyz, optional) – Vector (m), screen to object in screen reference frame, by default None. If None, the object reference frame is not plotted.
r_object_screen (Rotation, optional) – Rotation, object to screen reference frames, by default None. Only used if v_screen_object_screen is not None
opencsp.app.sofast.SofastGUI
GUI to control SOFAST image projection, image acquisition, and data capture. Can capture datasets and save to HDF format.
- class opencsp.app.sofast.SofastGUI.SofastGUI
Bases:
objectClass that contains SOFAST GUI controls and methods
- property cam_options
Returns all camera (ImageAcquisition) options that are compatible with Sofast
- close() None
Closes all windows
- close_image_acquisition() None
Close the single Image Acquisition object if open.
- close_projection_window() None
Close only projection window
- live_view() None
Shows live stream from the camera.
- load_gray_levels_cal() None
Loads saved results of a projector-camera intensity calibration
- load_image_acquisition() None
Loads and connects to ImageAcquisition
- load_image_projection() None
Loads and displays ImageProjection
- run_exposure_cal() None
Runs camera exposure calibration
- run_gray_levels_cal() None
Runs the projector-camera intensity calibration
- run_measurement() None
Runs data collect and saved data.
- save_snapshot() None
Save current snapshot from camera
- set_exposure() None
Sets camera exposure time value to user defined value
- show_axes() None
Shows ImageProjection axes
- show_calibration_fiducial_image() None
Shows calibration image with fiducials
- show_calibration_marker_image() None
Shows calibration image with Aruco markers
- show_crosshairs() None
Shows crosshairs
- show_snapshot() None
Captures frame and displays image and image histogram.
- Returns:
frame – 2D image array.
- Return type:
ndarray
- view_gray_levels_cal() None
Shows plot of gray levels calibration data
opencsp.app.sofast.lib.CalibrateDisplayShape
Class containing all screen distortion calibration routines. Saves distortion data and calibrated markers for camera position calibration.
- class opencsp.app.sofast.lib.CalibrateDisplayShape.CalibrateDisplayShape(data_input: DataInput)
Bases:
objectClass containing methods to calibrate screen distortion/position
- data_input
DataInput class with input data
- Type:
: DataInput
- make_figures
Set to True to output plots
- Type:
bool
- data_calculation
DataCalculation class for storing calculated data
- Type:
- figures
List containing generated figures, if not figures generated, empty list.
- Type:
list[plt.Figure]
- as_DisplayShape(name: str) DisplayShape
Returns calibrated DisplayShape object.
- Parameters:
name (str) – Name of DisplayShape.
- assemble_xyz_data_into_images() None
Assembles data into 2d arrays
- calculate_3d_screen_points() None
Calculates 3d screen points by intersecting camera rays
- get_data() dict
Returns dictionary with screen distortion data with fields: - pts_xy_screen_fraction: Vxy - pts_xyz_screen_coords: Vxyz
- interpolate_camera_pixel_positions() None
Interpolates the XY position of each camera pixel position for regular grids of screen fractions
- locate_camera_positions() None
Finds location of cameras in space using orientation points
- plot_ray_intersection_errors() None
Plots camera ray intersection errors
- run_calibration() None
Runs a complete calibration
- visualize_annotated_camera_images() None
Annotates images of screen with screen points
- visualize_final_scenario() None
Plots alignment points and screen points
- visualize_located_cameras() None
Plots cameras and alignment points
- visualize_unwrapped_phase() None
Visualizes x/y unwrapped phase for all poses
- visualize_xyz_screen_maps() None
Visualizes screen xyz coordinates as images
- class opencsp.app.sofast.lib.CalibrateDisplayShape.DataCalculation(pts_screen_frac_x: ndarray | None = None, pts_screen_frac_y: ndarray | None = None, cal_pattern_params: CalParams | None = None, pts_uv_pixel_orientation: list[Vxy] | None = None, pts_uv_pixel: list[Vxy] | None = None, num_points_screen: int | None = None, num_poses: int | None = None, rvecs: list[Rotation] | None = None, tvecs: list[Vxyz] | None = None, pts_xyz_screen_orientation: Vxyz | None = None, pts_xyz_screen_aligned: Vxyz | None = None, intersection_dists_mean: ndarray | None = None, intersection_points_mask: ndarray | None = None, im_x_screen_pts: Vxyz | None = None, im_y_screen_pts: Vxyz | None = None, im_z_screen_pts: Vxyz | None = None, masks: list[ndarray] | None = None, x_phase_list: list[ndarray] | None = None, y_phase_list: list[ndarray] | None = None)
Bases:
objectData class storing calculation data
- cal_pattern_params: CalParams = None
- intersection_dists_mean: ndarray = None
- intersection_points_mask: ndarray = None
- masks: list[ndarray] = None
- num_points_screen: int = None
- num_poses: int = None
- pts_screen_frac_x: ndarray = None
- pts_screen_frac_y: ndarray = None
- rvecs: list[Rotation] = None
- x_phase_list: list[ndarray] = None
- y_phase_list: list[ndarray] = None
- class opencsp.app.sofast.lib.CalibrateDisplayShape.DataInput(corner_ids: ndarray, screen_cal_point_pairs: ndarray, resolution_xy: tuple[int, int], pts_xyz_marker: Vxyz, camera: Camera, image_projection_data: ImageProjectionData, measurements_screen: list[MeasurementSofastFringe], assume_located_points: bool = True, ray_intersection_threshold: float = 0.001)
Bases:
objectData class storing input data for a CalibrateDisplayShape class
Parameters:
- corner_idsndarray
Corner IDs (marker ID * 4 + corner index). Does not have to be continuous
- screen_cal_point_pairsndarray
Two column ndarray [Screen calibration fiducial ID, marker ID]
- resolution_xytuple[int, int]
Resolution of output screen map
- pts_xyz_markerVxyz
Aruco marker corners, meters
- cameraCamera
Camera object used to capture screen distortion data
- image_projection_dataImageProjectionData
Image projection parameters
- measurements_screenlist[MeasurementSofastFringe]
Screen shape Sofast measurement objects
- assume_located_pointsbool
To assume that points are located accuratly, does not optimize point location, by default True.
- ray_intersection_thresholdfloat
Threshold to consider a valid intersection, meters, by default 0.001.
- assume_located_points: bool = True
- corner_ids: ndarray
- image_projection_data: ImageProjectionData
- measurements_screen: list[MeasurementSofastFringe]
- ray_intersection_threshold: float = 0.001
- resolution_xy: tuple[int, int]
- screen_cal_point_pairs: ndarray
- opencsp.app.sofast.lib.CalibrateDisplayShape.interp_xy_screen_positions(im_x: ndarray, im_y: ndarray, x_sc: ndarray, y_sc: ndarray) Vxy
Calculates the interpolated XY screen positions given X/Y fractional screen maps and X/Y interpolation vectors.
- Parameters:
im_x (np.ndarray) – 2D ndarray. X screen fraction image (fractional screens).
im_y (np.ndarray) – 2D ndarray. Y screen fraction image (fractional screens).
x_sc (np.ndarray) – 1D length N ndarray. X axis for output interpolated image. (fractionalscreens)
y_sc (np.ndarray) – 1D length M ndarray. Y axis for output interpolated image. (fractional screens)
- Returns:
Length (M * N) image coordinates corresponding to input interpolation axes (pixels).
- Return type: