Skip to content

Question about getting covariance using BACovariance and get_cam1_from_cam2_cov #3256

@moh-ake

Description

@moh-ake

Hello,

I am trying to obtain covariance matrices of poses using pycolmap. To do so, I followed the pycolmap documentation and the BACovariance unit test to write the Python code below. However, the 6x6 covariance matrices I get using get_cam1_from_cam2_cov seem to be incorrect.

Questions:

  • Does ba_covariance.get_cam1_from_cam2_cov(id1, id2) return the covariance of camera pose 1 with camera pose 2 as a reference , or does it return the covariance of the projection of 3D points from camera 2 to camera 1 ?
  • I would like to know if the code below correctly implements the process for running ba_covariance.get_cam1_from_cam2_cov(id1, id2), or if I'm missing any steps ?
################################################## reconstruction ##############################################
reconstruction = pycolmap.Reconstruction()
reconstruction.read("/Path/To/Reconstruction")

################################################## BA options ##############################################
ba_options = pycolmap.BundleAdjustmentOptions()

################################################## BA config ################################################
ba_config = pycolmap.BundleAdjustmentConfig()

# Add images
for image_id in reconstruction.reg_image_ids():
    ba_config.add_image(image_id)

# As mentioned in covariance_test.cc, we must fix
# the Gauge by always setting at least 3 points as constant
point_idx = 0
for point_id in reconstruction.point3D_ids():
    if point_idx >= 3:
        ba_config.add_variable_point(point_id)
    else:
        ba_config.add_constant_point(point_id)
        point_idx += 1

ba_config.set_constant_cam_intrinsics(1)

################################################## BA adjuster ################################################
bundle_adjuster = pycolmap.create_default_bundle_adjuster(options=ba_options, config=ba_config, reconstruction=reconstruction)
summary = bundle_adjuster.solve()
print(summary.IsSolutionUsable()) # Returns True

################################################## BA covariance ##############################################
ba_covariance_options = pycolmap.BACovarianceOptions()
ba_covariance_options.params = pycolmap.BACovarianceOptionsParams.POSES
ba_covariance = pycolmap.estimate_ba_covariance(
                                        options=ba_covariance_options,
                                        reconstruction=reconstruction,
                                        bundle_adjuster=bundle_adjuster)

ba_covariance.get_cam1_from_cam2_cov(1, 2)

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions