Class SceneStructureMetric

java.lang.Object
boofcv.abst.geo.bundle.SceneStructureCommon
boofcv.abst.geo.bundle.SceneStructureMetric
All Implemented Interfaces:
SceneStructure

public class SceneStructureMetric extends SceneStructureCommon
Specifies a metric (calibrated) scene for optimizing using BundleAdjustment. It specifies the relationships between cameras, views, and points. A camera projects a 3D point onto the image plane. Examples of specific models include pinhole and fisheye. A view is a set of observed features from a specific camera image. Views have an associated camera and specify the pose of the camera when the scene was viewed. Points describe the scene's 3D structure. Points belonging to the general scene and rigid objects have two different sets of ID's.
  • Field Details

  • Constructor Details

    • SceneStructureMetric

      public SceneStructureMetric(boolean homogenous)
      Configure bundle adjustment
      Parameters:
      homogenous - if true then homogeneous coordinates are used
  • Method Details

    • initialize

      public void initialize(int totalCameras, int totalViews, int totalPoints)
      Call this function first. Specifies number of each type of data which is available.
      Parameters:
      totalCameras - Number of cameras
      totalViews - Number of views
      totalPoints - Number of points
    • initialize

      public void initialize(int totalCameras, int totalViews, int totalMotions, int totalPoints, int totalRigid)
      Call this function first. Specifies number of each type of data which is available.
      Parameters:
      totalCameras - Number of cameras
      totalViews - Number of views
      totalMotions - Number of motions
      totalPoints - Number of points
      totalRigid - Number of rigid objects
    • assignIDsToRigidPoints

      public void assignIDsToRigidPoints()
      Assigns an ID to all rigid points. Call this function after the structure of all the rigid objects has been specified. You must call this before you assign observations to rigid bodies,
    • getParentToView

      public Se3_F64 getParentToView(SceneStructureMetric.View view)
      Returns SE3 relationship to the specified view from its parent.
      Parameters:
      view - The target view
      Returns:
      SE3 transform from parent to view.
    • getParentToView

      public Se3_F64 getParentToView(int viewIdx)
      Returns SE3 relationship to the specified view from its parent.
      Parameters:
      viewIdx - Index of target view
      Returns:
      SE3 transform from parent to view.
    • getWorldToView

      public Se3_F64 getWorldToView(SceneStructureMetric.View view, @Nullable @Nullable Se3_F64 world_to_view, @Nullable @Nullable Se3_F64 tmp)
      Computes and returns the transform from world to view. If the view is relative then the chain is followed
      Parameters:
      view - The target view
      world_to_view - Storage for the found transform. Can be null.
      tmp - Optional workspace to avoid creating new memory. Can be null;
      Returns:
      SE3 transform from parent to view.
    • getViewToView

      public Se3_F64 getViewToView(SceneStructureMetric.View view1, SceneStructureMetric.View view2)
      Computes and returns the transform from view1 to view2
      Parameters:
      view1 - First view
      view2 - Second view
      Returns:
      SE3 transform from view1 to view2.
    • getViewToView

      public Se3_F64 getViewToView(int view1, int view2)
      Computes and returns the transform from view1 to view2. See getViewToView(View, View).
    • hasRigid

      public boolean hasRigid()
      Returns true if the scene contains rigid objects
    • setView

      public void setView(int viewIndex, int cameraIndex, boolean known, Se3_F64 world_to_view)
      Specifies the spacial transform for a view and assumes the parent is the world frame.
      Parameters:
      viewIndex - Which view is being specified.
      cameraIndex - Index of camera model
      known - If these parameters are fixed or not
      world_to_view - The transform from world to view reference frames. Internal copy is saved.
    • setView

      public void setView(int viewIndex, int cameraIndex, boolean known, Se3_F64 parent_to_view, int parent)
      Specifies the spacial transform for a view and assumes the parent is the world frame.
      Parameters:
      viewIndex - Which view is being specified.
      cameraIndex - Index of camera model
      known - If the parameters are known and not optimized or unknown and optimized
      parent_to_view - The transform from parent to view reference frames. Internal copy is saved.
      parent - ID / index of the parent this this view is relative to
    • setView

      public void setView(int viewIndex, int cameraIndex, int motionIndex, int parent)
      Specifies which motion is attached to a view
      Parameters:
      viewIndex - Which view is being specified.
      cameraIndex - Index of camera model
      motionIndex - The motion that describes the parent_to_view relationship
      parent - ID / index of the parent this this view is relative to
    • addMotion

      public int addMotion(boolean known, Se3_F64 parentToView)
      Specifies a new motion.
      Parameters:
      known - If the parameters are known and not optimized or unknown and optimized
      parentToView - Specifies motion from parent to view reference frames
      Returns:
      Index or ID for the created motion
    • setRigid

      public void setRigid(int which, boolean known, Se3_F64 objectToWorld, int totalPoints)
      Declares the data structure for a rigid object. Location of points are set by accessing the object directly. Rigid objects are useful in known scenes with calibration targets.
      Parameters:
      which - Index of rigid object
      known - If the parameters are known and not optimized or unknown and optimized
      objectToWorld - Initial estimated location of rigid object
      totalPoints - Total number of points attached to this rigid object
    • connectViewToCamera

      public void connectViewToCamera(int viewIndex, int cameraIndex)
      Specifies that the view uses the specified camera
      Parameters:
      viewIndex - index of view
      cameraIndex - index of camera
    • getUnknownCameraCount

      public int getUnknownCameraCount()
      Returns the number of cameras with parameters that are not fixed
      Returns:
      non-fixed camera count
    • getUnknownMotionCount

      public int getUnknownMotionCount()
      Returns the number of motions with parameters that are not fixed
      Returns:
      non-fixed view count
    • getUnknownRigidCount

      public int getUnknownRigidCount()
      Returns the number of view with parameters that are not fixed
      Returns:
      non-fixed view count
    • getTotalRigidPoints

      public int getTotalRigidPoints()
      Returns total number of points associated with rigid objects.
    • projectToPixel

      public boolean projectToPixel(int pointIdx, int viewIdx, @Nullable @Nullable BundleCameraState cameraState, Se3_F64 world_to_view, Se3_F64 tmpSE, Point3D_F64 tmpX, Point2D_F64 pixel)
      Projects the requested point onto the requested view and computes its predicted pixel coordinates.
      Parameters:
      pointIdx - (Input) index of point
      viewIdx - (Input) index of view
      world_to_view - (Output) Internal work space
      tmpSE - (Output) Internal work space
      tmpX - (Output) Internal work space
      pixel - (Output) The projected pixel
      Returns:
      true if it's in front of the camera or false if it's behind
    • getViewCamera

      Returns the camera for this particular view
    • getViewCamera

      public SceneStructureCommon.Camera getViewCamera(int viewIdx)
      Returns the camera for this particular view
    • getParameterCount

      public int getParameterCount()
      Returns the total number of parameters which will be optimised
      Returns:
      number of parameters
    • getRigid

      public SceneStructureMetric.Rigid getRigid(int rigidIdx)
      Returns the specified SceneStructureMetric.Rigid.
    • isIdentical

      public boolean isIdentical(SceneStructureMetric m, double tol)
      Checks to see if the passed in scene is identical to "this" scene. Floating point values are checked to within tolerance
      Returns:
      true if identical to within specified float tolerance and false if not