Scene Reconstruction

(“r” prefix to ignore escape characters within docstring.)

Exercise scene reconstruction algorithms.

Supports these use cases:

  1. Pytest execution. Purpose: To verify code is still operating properly.

    1. Quick pytest unit tests. Run pytest from opencsp directory. In OpenCSP directory: pytest

    2. More detailed pytest examples. In OpenCSPexample directory: pytest

    3. Automated tests for pull request management.

    4. Automated tests for nightly and weekly function checks. Run pytest from opencsp/example directory (with arguments to run full-scale data).

    5. Run pytest on only this example. In OpenCSPexample directory: pytest .scene_reconstructionexample_scene_reconstruction.py

  2. Running the example from the command line. Purpose: To apply the example calculation to new data.

    1. With no arguments, to execute default behavior (for practice and study). In OpenCSPexamplescene_reconstruction directory: python .example_scene_reconstruction.py

    2. With an argument to read a user-specified settings file to define input sources, output locations, and execution details. i. Data source/sink options:

      1. Data built into the repository. No argument. In OpenCSPexamplescene_reconstruction directory: python .example_scene_reconstruction.py

      2. Community data on local machine. myfile_ctemp.ini In OpenCSPexamplescene_reconstruction directory: python .example_scene_reconstruction.py –settings_dir_body_ext “C:ctempOpenCSP_ctempexample_scene_reconstruction_settings_ctemp.ini”

      3. Data on local machine, but in user-owned location. myfile_<user_id>.ini In OpenCSPexamplescene_reconstruction directory: python .example_scene_reconstruction.py –settings_dir_body_ext “C:Users<user_id>OpenCSPOpenCSP_<user_id>example_scene_reconstruction_settings_<user_id>.ini”

      4. General network location. myfile_<network_location>.ini In OpenCSPexamplescene_reconstruction directory: python .example_scene_reconstruction.py –settings_dir_body_ext “\<network_path>OpenCSP_<net_name>example_scene_reconstruction_settings_<net_name>.ini”

      1. Output levels:

      1. Output only minimal progress updates. Omit –verbose flag.

      2. Output full progress and calculation updates. Add –verbose flag.

    3. Review command-line options: In OpenCSPexamplescene_reconstruction directory: python .example_scene_reconstruction.py –help

  3. Calling the example calculation from other code. Purpose: To utilize the example calculation within a larger computation or application.

    1. Arbitrary context and general data. In calling file, import example_scenario_reconstruction, call driver.

  4. Running an example with the Visual Studio Code debugger. Purpose: To interact with the code execution (break points, check stack variables, etc), either for study or fixing an error. Could apply to either 2 or 3 above.

    1. Use default settings, running on default data. In VS Code, press F5 key.

    2. Temporarily modify internal variable values to test specific data computation. Make a scratch copy somewhere else, edit in VS Code, then press F5 key.

example.scene_reconstruction.example_scene_reconstruction.example_scene_reconstruction_driver(arg_settings_dir_body_ext: str | None = None, verbose_param=None)

Sets up and runs the scene_reconstruction() routine.

Parameters:
  • arg_settings_dir_body_ext (str) – Full path and filename for settings file, containing inputand output directories, plot control settings, etc. Optional. If not provided, internal defaults are used. See code for options sought within file.

  • verbose (bool) – If true, output detailed progress and calculation output.

example.scene_reconstruction.example_scene_reconstruction.scene_reconstruction(dir_input, dir_output, verbose)

Reconstructs the XYZ locations of Aruco markers in a scene.

Parameters:
  • dir_input (str) –

    The directory containing the input files needed for scene reconstruction. This includes:

    • ’camera.h5’: HDF5 file containing camera parameters.

    • ’known_point_locations.csv’: CSV file with known point locations.

    • ’aruco_marker_images/NAME.JPG’: Directory containing images of Aruco markers.

    • ’point_pair_distances.csv’: CSV file with distances between point pairs.

    • ’alignment_points.csv’: CSV file with alignment points.

  • dir_output (str) – The directory where the output files, including point locations and calibration figures, will be saved.

  • verbose (bool) – If true, write out detailed information.

Notes

This function performs the following steps:

  1. Loads the camera parameters from an HDF5 file.

  2. Loads known point locations, point pair distances, and alignment points from CSV files.

  3. Initializes the SceneReconstruction object with the camera parameters and known point locations.

  4. Runs the calibration process to determine the marker positions.

  5. Scales the points based on the provided point pair distances.

  6. Aligns the points using the provided alignment points.

  7. Saves the reconstructed point locations to a CSV file.

  8. Saves calibration figures as PNG files in the output directory.

Examples

>>> scene_reconstruction('/path/to/input', '/path/to/output')