opencsp.app.scene_reconstruction.lib.SceneReconstruction

Photogrammetric reconstruction class based on images of Aruco markers

class opencsp.app.scene_reconstruction.lib.SceneReconstruction.SceneReconstruction(camera: Camera, known_point_locations: ndarray, image_filter_path: str)

Bases: object

Class containing methods and analysis algorithms to reconstruct a 3d scene of Aruco markers.

make_figures

To make output figures, by default, False.

Type:

bool

intersect_threshold

Maximum point to ray distance to be considered an intersection during triangulation, by default 0.02 meters.

Type:

float

align_points(marker_ids: ndarray[int], alignment_values: Vxyz, apply_scale: bool = False) None

Aligns selected markers origin points (corner index 0) within point cloud to match given alignment values. Set to NAN for floating. Points are aligned FIRST, then transformed. (Must be applied after conversion to the four point model)

See align_points() of photogrammetry.py for more information.

Parameters:
  • marker_ids (ndarray[int]) – (N,) array of MARKER IDs

  • alignment_values (Vxyz) – (N, 3) array of optimal point locations of marker origin point (corner 0)

  • apply_scales (bool) – To scale points or just align.

property all_image_rvecs: ndarray

Returns all rvecs for all images in Nx3 array

property all_image_tvecs: ndarray

Returns all tvecs for all images in Nx3 array

attempt_all_camera_pose_calculation() None

Attempt to calculate poses of all cameras

attempt_all_points_triangulation(intersect_thres: float = 0.02) None

Attemps to calculate position of all unknown points using ray intersection

Parameters:

intersect_thres (float, optional) – Maximum point to ray distance to be considered an intersection, by default 0.02

calculate_mean_reproj_errors() ndarray

Returns array of reprojection errors. For each located camera, saves mean reprojection errors of all located points. NaN if pose is unlocated.

convert_to_four_corners() None

Converts all images to four corner images instead of single points

get_data() ndarray

Returns marker IDs, point IDs, and point locations in one array

Returns:

Marker ID, point ID, X, Y, Z

Return type:

Nx4 ndarray.

load_images() None

Saves loaded dataset in class

property located_camera_idxs: ndarray

Returns image indices of cameras with known poses

located_images_with_view_of_marker(id_: int) list[ImageMarker]

Returns list of located images that have view of given marker

Parameters:

id (int) – Marker ID to find

Return type:

list[ImageMarker]

log_located_points_cameras() None

Logs currently located cameras and markers

log_point_location_summary() None

Logs short summary of current progress

log_reprojection_error_summary() None

Logs reprojection error summary

optimize(intersect_thresh: float = 0.02) None

Runs point location optimization routine

Parameters:

intersect_thres (float, optional) – Maximum point to ray distance to be considered an intersection, by default 0.02

plot_point_camera_summary() None

Plots situational summary: Camera poses and point locations

plot_reprojection_errors() None

Plots mean reprojection error magnitude vs camera pose

refine_located_poses_and_points() None

Performs bundle adjustment on located points and poses

run_calibration() None

Runs the calibration sequence

save_all_as_hdf(directory: str) None

Saves all ImageMarkers as HDF files in given directory

save_data_as_csv(file: str) None

Saves the location of all marker points in given CSV file. Columns are [Marker ID, Corner ID, x, y, z]

save_ids_known() None

Loads known marker IDs and their locations

scale_points(point_pairs: ndarray[int], distances: ndarray[float]) None

Scales point locations to match measured distances between pairs of Aruco marker origin points (corner 0). (Must be applied after conversion to the four point model)

Parameters:
  • point_pairs (ndarray) – Nx2 array of point pairs indices (MARKER IDs)

  • distances (ndarray) – (N,) array of distances between point pairs

set_id_known(id_: int, pt: ndarray) None

Sets given ID as known in all images

Parameters:
  • id (int) – Marker ID to set

  • pt (np.ndarray) – Shape (3,) ndarray xyz point location

set_ids_known(ids: Iterable[int], pts: ndarray) None

Sets multiple IDs known in all images

Parameters:
  • ids (Iterable[int]) – Marker IDs to set

  • pts (ndarray) – Nx3 ndarray of marker ID locations

property unlocated_marker_ids: ndarray

Returns all unlocated marker IDs