Package boofcv.alg.geo.structure
Class ProjectiveStructureByFactorization
- java.lang.Object
-
- boofcv.alg.geo.structure.ProjectiveStructureByFactorization
-
public class ProjectiveStructureByFactorization extends java.lang.ObjectPerforms projective reconstruction via factorization. For every view all points are observed. The algorithm works by iteratively estimating the depth of each point in every view and this results in better and better estimates of the projective camera matrices and the points being found. An initial estimate of feature depth can be provided. Unfortunately, there is no grantee of this method converging to a valid solution.[ λ[1,1]*x[1,1] , λ[1,2]*x[1,2] , ... , λ[1,M]*x[1,M] ] = [ P[1] ] * [X[1], X[2], ... , X[N] [ λ[2,1]*x[1,1] , λ[2,2]*x[1,2] , ... , λ[2,M]*x[2,M] ] = [ P[2] ] [ ... ] = [ ... ] [ λ[N,1]*x[1,1] , λ[N,2]*x[1,2] , ... , λ[N,M]*x[N,M] ] = [ P[M] ]
where λ is the depth, x is homogenous pixel coordinate, P is 3x4 projective, X is 3D feature location in world coordinate system. Procedure:- Call
initialize(int, int)and specify the system's size - Set initial pixel depths
- Set pixel observations for each view
- Call
process() - Get results with
getFeature3D(int, georegression.struct.point.Point4D_F64)andgetCameraMatrix(int, org.ejml.data.DMatrixRMaj)
Internally depth and pixel values are scaled so that they are close to unity then undo for output. This ensures better approximation of errors and has other desirable numerical properties.
[1] Page 444 in R. Hartley, and A. Zisserman, "Multiple View Geometry in Computer Vision", 2nd Ed, Cambridge 2003
- Call
-
-
Constructor Summary
Constructors Constructor Description ProjectiveStructureByFactorization()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassignValuesToA(org.ejml.data.DMatrixRMaj A)A[:,0] = depth*[x,y,1]'voidgetCameraMatrix(int view, org.ejml.data.DMatrixRMaj cameraMatrix)Used to get found camera matrix for a viewvoidgetFeature3D(int feature, georegression.struct.point.Point4D_F64 out)Returns location of 3D feature for a viewintgetMaxIterations()doublegetMinimumChangeTol()voidinitialize(int numFeatures, int numViews)Initializes internal data structures.voidnormalizeDepths(org.ejml.data.DMatrixRMaj depths)Rescale A so that its rows and columns have a value of approximately 1.booleanprocess()Performs iteration to find camera matrices and feature locations in world framevoidsetAllDepths(double value)Sets all depths to an initial valuevoidsetDepths(int view, double[] featureDepths)Sets depths for a particular value to the values in the passed in arrayvoidsetDepthsFrom3D(int view, java.util.List<georegression.struct.point.Point3D_F64> locations)Assigns depth to the z value of all the features in the list.voidsetMaxIterations(int maxIterations)voidsetMinimumChangeTol(double minimumChangeTol)voidsetPixels(int view, java.util.List<georegression.struct.point.Point2D_F64> pixelsInView)Sets pixel observations for a paricular view
-
-
-
Method Detail
-
initialize
public void initialize(int numFeatures, int numViews)Initializes internal data structures. Must be called first- Parameters:
numFeatures- Number of featuresnumViews- Number of views
-
setPixels
public void setPixels(int view, java.util.List<georegression.struct.point.Point2D_F64> pixelsInView)Sets pixel observations for a paricular view- Parameters:
view- the viewpixelsInView- list of 2D pixel observations
-
setAllDepths
public void setAllDepths(double value)
Sets all depths to an initial value- Parameters:
value-
-
setDepths
public void setDepths(int view, double[] featureDepths)Sets depths for a particular value to the values in the passed in array- Parameters:
view-featureDepths-
-
setDepthsFrom3D
public void setDepthsFrom3D(int view, java.util.List<georegression.struct.point.Point3D_F64> locations)Assigns depth to the z value of all the features in the list. Features must be in the coordinate system of the view for this to be correct- Parameters:
view- which view is features are inlocations- Location of features in the view's reference frame
-
process
public boolean process()
Performs iteration to find camera matrices and feature locations in world frame- Returns:
- true if no exception was thrown. Does not mean it converged to a valid solution
-
getCameraMatrix
public void getCameraMatrix(int view, org.ejml.data.DMatrixRMaj cameraMatrix)Used to get found camera matrix for a view- Parameters:
view- Which viewcameraMatrix- storage for 3x4 projective camera matrix
-
getFeature3D
public void getFeature3D(int feature, georegression.struct.point.Point4D_F64 out)Returns location of 3D feature for a view- Parameters:
feature- Index of feature to retrieveout- (Output) Storage for 3D feature. homogenous coordinates
-
assignValuesToA
public void assignValuesToA(org.ejml.data.DMatrixRMaj A)
A[:,0] = depth*[x,y,1]'
-
normalizeDepths
public void normalizeDepths(org.ejml.data.DMatrixRMaj depths)
Rescale A so that its rows and columns have a value of approximately 1. This is done to try to get everything set to unity for desirable numerical properties
(α β λ) x = (αP)(βX)
-
getMaxIterations
public int getMaxIterations()
-
setMaxIterations
public void setMaxIterations(int maxIterations)
-
getMinimumChangeTol
public double getMinimumChangeTol()
-
setMinimumChangeTol
public void setMinimumChangeTol(double minimumChangeTol)
-
-