Package boofcv.alg.geo.structure
Class ProjectiveStructureByFactorization
java.lang.Object
boofcv.alg.geo.structure.ProjectiveStructureByFactorization
Performs 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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
A[:,0] = depth*[x,y,1]'void
getCameraMatrix
(int view, DMatrixRMaj cameraMatrix) Used to get found camera matrix for a viewvoid
getFeature3D
(int feature, Point4D_F64 out) Returns location of 3D feature for a viewint
double
void
initialize
(int numFeatures, int numViews) Initializes internal data structures.void
normalizeDepths
(DMatrixRMaj depths) Rescale A so that its rows and columns have a value of approximately 1.boolean
process()
Performs iteration to find camera matrices and feature locations in world framevoid
setAllDepths
(double value) Sets all depths to an initial valuevoid
setDepths
(int view, double[] featureDepths) Sets depths for a particular value to the values in the passed in arrayvoid
setDepthsFrom3D
(int view, List<Point3D_F64> locations) Assigns depth to the z value of all the features in the list.void
setMaxIterations
(int maxIterations) void
setMinimumChangeTol
(double minimumChangeTol) void
setPixels
(int view, List<Point2D_F64> pixelsInView) Sets pixel observations for a paricular view
-
Constructor Details
-
ProjectiveStructureByFactorization
public ProjectiveStructureByFactorization()
-
-
Method Details
-
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
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 -
setDepths
public void setDepths(int view, double[] featureDepths) Sets depths for a particular value to the values in the passed in array -
setDepthsFrom3D
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
Used to get found camera matrix for a view- Parameters:
view
- Which viewcameraMatrix
- storage for 3x4 projective camera matrix
-
getFeature3D
Returns location of 3D feature for a view- Parameters:
feature
- Index of feature to retrieveout
- (Output) Storage for 3D feature. homogenous coordinates
-
assignValuesToA
A[:,0] = depth*[x,y,1]' -
normalizeDepths
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)
-