upsp.cam_cal_utils.target_bumping

get_bumping_occlusion(tgt, vis_checker)[source]

Helper function to tgts_get_internals() that finds the point on the model surface that intersects the tgt normal vector if the target is occluded by the model

Parameters
  • tgt (dict) – A dict and has, at a minimum, the keys ‘tvec’, ‘target_type’, ‘norm’. ‘tvec’ has a numpy.ndarray (3, 1) representing the position of the target relative to the model origin for its associated value. ‘norm’ has a numpy.ndarray (3, 1) representing the normal vector of the target relative to the model origin for its associated value. ‘target_type’ has a string representing the type of target (most commonly ‘dot’) for its associated value.

  • vis_checker (VisibilityChecker) – BVH to check for visibilty of nodes

Returns

  • occlusion (bool) – Whether or not there is an occlusion. True means there is, False means there is not.

  • location (numpy.ndarray, shape (3,)) – Location where the tgt normal vector intersects the model surface

  • dist (float) – Distance from the target position to the point of intersection

is_real_occlusion(bumping_occlusion, tgts_tol, grid_tol)[source]

Helper function to tgts_get_internals() that determines if an occlusion is due to real geometry, or is a numerical/processing error in generating the tgts file

Parameters
  • bumping_occlusion (tuple) – Return value of get_bumping_occlusion() for the target associated with the function call

  • vis_checker (VisibilityChecker) – BVH to check for visibilty of nodes

  • tgts_tol (float, optional) – Tolerance of the tgts file. Used to determine if target internal-ness is real, or if it is an artifact due to the non-water tightness of the model grid

  • grid_tol (float, optional) – Tolerance of the grid file. Used to determine if target internal-ness is real, or if it is an artifact due to the non-water tightness of the model grid

Returns

True if the occlusion is due to real geometry

Return type

bool

tgt_bump_externals(tgts, vis_checker, bump_eps=1e-05)[source]

Bumps very external targets to be slightly external. Slightly external defined by bump_eps

Parameters
  • tgts (list of dict) – Each target is a dict and has, at a minimum, the keys ‘tvec’, ‘target_type’, ‘norm’. ‘tvec’ has a numpy.ndarray (3, 1) representing the position of the target relative to the model origin for its associated value. ‘norm’ has a np.ndarray (3, 1) representing the normal vector of the target relative to the model origin for its associated value. ‘target_type’ has a string representing the type of target (most commonly ‘dot’) for its associated value.

  • vis_checker (VisibilityChecker) – BVH to check for visibilty of nodes

  • bump_eps (float, optional) – Distance to bump the targets outside the model. Should be small so targets are just barely external to the model

Returns

tgts_bumped – Copy of tgts with some target positions bumped along their normal to be slightly external

Return type

list of dict

tgt_bump_internals(tgts, vis_checker, bump_eps=1e-05, tgts_tol=0.1, grid_tol=0.001)[source]

Bumps all internal targets along their normal to be slightly external. Slightly external defined by bump_eps

Parameters
  • tgts (list of dict) – Each target is a dict and has, at a minimum, the keys ‘tvec’, ‘target_type’, ‘norm’. ‘tvec’ has a numpy.ndarray (3, 1) representing the position of the target relative to the model origin for its associated value. ‘norm’ has a np.ndarray (3, 1) representing the normal vector of the target relative to the model origin for its associated value. ‘target_type’ has a string representing the type of target (most commonly ‘dot’) for its associated value.

  • vis_checker (VisibilityChecker) – BVH to check for visibilty of nodes

  • bump_eps (float, optional) – Distance to bump the targets outside the model. Should be small so targets are just barely external to the model

  • tgts_tol (float, optional) – Tolerance of the tgts file. Used to determine if target internal-ness is real, or if it is an artifact due to the non-water tightness of the model grid

  • grid_tol (float, optional) – Tolerance of the grid file. Used to determine if target internal-ness is real, or if it is an artifact due to the non-water tightness of the model grid

Returns

  • tgts_bumped (list of dict) – Copy of tgts with some target positions bumped along their normal to be slightly external.

  • was_bumped (bool) – Denotes if any targets were bumped

tgts_bumper(tgts, vis_checker, bump_eps=1e-05, tgts_tol=0.1, grid_tol=0.001)[source]

Bumps all internal targets along their normal to be slightly external. Bumps any targets very external to be slightly external

Parameters
  • tgts (list of dict) – Each target is a dict and has, at a minimum, the keys ‘tvec’, ‘target_type’, ‘norm’. ‘tvec’ has a numpy.ndarray (3, 1) representing the position of the target relative to the model origin for its associated value. ‘norm’ has a np.ndarray (3, 1) representing the normal vector of the target relative to the model origin for its associated value. ‘target_type’ has a string representing the type of target (most commonly ‘dot’) for its associated value.

  • vis_checker (VisibilityChecker) – BVH to check for visibilty of nodes

  • bump_eps (float, optional) – Distance to bump the targets outside the model. Should be small so targets are just barely external to the model

  • tgts_tol (float, optional) – Tolerance of the tgts file. Used to determine if target internal-ness is real, or if it is an artifact due to the non-water tightness of the model grid

  • grid_tol (float, optional) – Tolerance of the grid file. Used to determine if target internal-ness is real, or if it is an artifact due to the non-water tightness of the model grid

Returns

bumped_external_targets – Copy of tgts input with the ‘tvec’ values modified so that each tgt is outside the grid of vis_checker

Return type

list of dict

tgts_file_bumper(tgts_file_path, vis_checker, bump_eps=1e-05, tgts_tol=0.1, grid_tol=0.001)[source]

Creates a tgts file with all internal targets bumped along their normal to be slightly external and very external targets to be slightly external

Creates a new tgts file in the same directory as tgts_file_path with the same name, but with the suffix ‘_bumped’ attached to the filename

Parameters
  • tgts_file_path (path-like) – Path to the tgts file

  • vis_checker (VisibilityChecker) – BVH to check for visibilty of nodes

  • bump_eps (float, optional) – Distance to bump the targets outside the model. Should be small so targets are just barely external to the model

  • tgts_tol (float, optional) – Tolerance of the tgts file. Used to determine if target internal-ness is real, or if it is an artifact due to the non-water tightness of the model grid

  • grid_tol (float, optional) – Tolerance of the grid file. Used to determine if target internal-ness is real, or if it is an artifact due to the non-water tightness of the model grid

tgts_get_internals(tgts, vis_checker, tgts_tol=0.0001, grid_tol=0.001)[source]

Helper function to ltgt_bump_internals() that returns all internal targets

Parameters
  • tgts (list of dict) – Each target is a dict and has, at a minimum, the keys ‘tvec’, ‘target_type’, ‘norm’. ‘tvec’ has a numpy.ndarray (3, 1) representing the position of the target relative to the model origin for its associated value. ‘norm’ has a np.ndarray (3, 1) representing the normal vector of the target relative to the model origin for its associated value. ‘target_type’ has a string representing the type of target (most commonly ‘dot’) for its associated value.

  • vis_checker (VisibilityChecker) – BVH to check for visibilty of nodes

  • tgts_tol (float, optional) – Tolerance of the tgts file. Used to determine if target internal-ness is real, or if it is an artifact due to the non-water tightness of the model grid

  • grid_tol (float, optional) – Tolerance of the grid file. Used to determine if target internal-ness is real, or if it is an artifact due to the non-water tightness of the model grid

Returns

Each tuple is an occluded targets. The first item in the tuple is the target name. The second element is a boolean to denote if it is a real occlusion (like another part of the model is blocking the target so it should not be bumped) or just some accidental occlusion due to being differentiably inside the model grid

Return type

list of tuple