Package boofcv.alg.fiducial.square
Class QuadPoseEstimator
java.lang.Object
boofcv.alg.fiducial.square.QuadPoseEstimator
Estimates the pose using P3P and iterative refinement from 4 points on a plane with known locations. While
this seems like it would be a trivial problem it actually takes several techniques to ensure accurate results.
At a high level it uses P3P to provide an estimate. If the error is large it then uses EPNP. Which ever
is better it then refines. If the target is small and directly facing the camera it will enlarge the target
to estimate it's orientation. Otherwise it will over fit location since it takes a large change in orientation
to influence the result.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected doubleprotected Se3_F64static final doubleprotected List<Point2D_F64>protected Point2Transform2_F64protected Point2Transform2_F64static final double -
Constructor Summary
ConstructorsConstructorDescriptionQuadPoseEstimator(double refineTol, int refineIterations) Constructor which picks reasonable and generally good algorithms for pose estimation.QuadPoseEstimator(EstimateNofPnP p3p, RefinePnP refine) Constructor in which internal estimation algorithms are provided -
Method Summary
Modifier and TypeMethodDescriptionprotected doublecomputeErrors(Se3_F64 fiducialToCamera) Compute the sum of reprojection errors for all four pointsprotected voidenlarge(Quadrilateral_F64 corners, double scale) Enlarges the quadrilateral to make it more sensitive to changes in orientationprotected booleanestimate(Quadrilateral_F64 cornersPixels, Quadrilateral_F64 cornersNorm, Se3_F64 foundFiducialToCamera) Given the observed corners of the quad in the image in pixels estimate and store the results of its poseprotected voidestimateP3P(int excluded) Estimates the pose using P3P from 3 out of 4 points.protected voidextend(Point2D_F64 pivot, Point2D_F64 corner, double scale) doublegetError()Reprojection error of fiducialvoidpixelToMarker(double pixelX, double pixelY, Point2D_F64 marker) Given the found solution, compute the the observed pixel would appear on the marker's surface.booleanprocess(Quadrilateral_F64 corners, boolean unitsPixels) Estimate the 3D pose of the camera from the observed location of the fiducial.voidsetFiducial(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3) Specify the location of points on the 2D fiducial.voidsetLensDistoriton(LensDistortionNarrowFOV distortion) Specifies the intrinsic parameters.
-
Field Details
-
SMALL_PIXELS
public static final double SMALL_PIXELS- See Also:
-
FUDGE_FACTOR
public static final double FUDGE_FACTOR- See Also:
-
pixelToNorm
-
normToPixel
-
points
-
listObs
-
bestError
protected double bestError -
bestPose
-
-
Constructor Details
-
QuadPoseEstimator
public QuadPoseEstimator(double refineTol, int refineIterations) Constructor which picks reasonable and generally good algorithms for pose estimation.- Parameters:
refineTol- Convergence tolerance. Try 1e-8refineIterations- Number of refinement iterations. Try 200
-
QuadPoseEstimator
Constructor in which internal estimation algorithms are provided
-
-
Method Details
-
setLensDistoriton
Specifies the intrinsic parameters.- Parameters:
distortion- Intrinsic camera parameters
-
setFiducial
public void setFiducial(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3) Specify the location of points on the 2D fiducial. These should be in "world coordinates" -
pixelToMarker
Given the found solution, compute the the observed pixel would appear on the marker's surface. pixel -> normalized pixel -> rotated -> projected on to plane- Parameters:
pixelX- (Input) pixel coordinatepixelY- (Input) pixel coordinatemarker- (Output) location on the marker
-
process
Estimate the 3D pose of the camera from the observed location of the fiducial.
MUST callsetFiducial(double, double, double, double, double, double, double, double)andsetLensDistoriton(boofcv.alg.distort.LensDistortionNarrowFOV)before calling this function.- Parameters:
corners- Observed corners of the fiducial.unitsPixels- If true the specified corners are in original image pixels or false for normalized image coordinates- Returns:
- true if successful or false if not
-
estimate
protected boolean estimate(Quadrilateral_F64 cornersPixels, Quadrilateral_F64 cornersNorm, Se3_F64 foundFiducialToCamera) Given the observed corners of the quad in the image in pixels estimate and store the results of its pose -
estimateP3P
protected void estimateP3P(int excluded) Estimates the pose using P3P from 3 out of 4 points. Then use all 4 to pick the best solution- Parameters:
excluded- which corner to exclude and use to check the answers from the others
-
enlarge
Enlarges the quadrilateral to make it more sensitive to changes in orientation -
extend
-
computeErrors
Compute the sum of reprojection errors for all four points- Parameters:
fiducialToCamera- Transform being evaluated- Returns:
- sum of Euclidean-squared errors
-
getWorldToCamera
-
getError
public double getError()Reprojection error of fiducial -
createCopyPoints2D3D
-