use of boofcv.struct.distort.Point2Transform2_F32 in project BoofCV by lessthanoptimal.
the class PinholeRadialToEquirectangular_F32 method setPinhole.
/**
* Specifies the pinhole camera
* @param pinhole intrinsic parameters of pinhole camera
*/
public void setPinhole(CameraPinholeRadial pinhole) {
this.pinhole = pinhole;
declareVectors(pinhole.width, pinhole.height);
// computing the 3D ray through each pixel in the pinhole camera at it's canonical
// location
Point2Transform2_F32 pixelToNormalized = new LensDistortionRadialTangential(pinhole).undistort_F32(true, false);
Point2D_F32 norm = new Point2D_F32();
for (int pixelY = 0; pixelY < pinhole.height; pixelY++) {
for (int pixelX = 0; pixelX < pinhole.width; pixelX++) {
pixelToNormalized.compute(pixelX, pixelY, norm);
Point3D_F32 v = vectors[pixelY * pinhole.width + pixelX];
v.set(norm.x, norm.y, 1);
}
}
}
use of boofcv.struct.distort.Point2Transform2_F32 in project BoofCV by lessthanoptimal.
the class ImplRectifyImageOps_F32 method transformPixelToRectNorm.
public static Point2Transform2_F32 transformPixelToRectNorm(CameraPinholeRadial param, FMatrixRMaj rectify, FMatrixRMaj rectifyK) {
if (rectifyK.get(0, 1) != 0)
throw new IllegalArgumentException("Skew should be zero in rectified images");
Point2Transform2_F32 remove_p_to_p = narrow(param).undistort_F32(true, true);
PointTransformHomography_F32 rectifyDistort = new PointTransformHomography_F32(rectify);
PinholePtoN_F32 pixelToNorm = new PinholePtoN_F32();
pixelToNorm.set(rectifyK.get(0, 0), rectifyK.get(1, 1), rectifyK.get(0, 1), rectifyK.get(0, 2), rectifyK.get(1, 2));
return new SequencePoint2Transform2_F32(remove_p_to_p, rectifyDistort, pixelToNorm);
}
use of boofcv.struct.distort.Point2Transform2_F32 in project BoofCV by lessthanoptimal.
the class ImplRectifyImageOps_F32 method transformRectToPixel.
public static Point2Transform2_F32 transformRectToPixel(CameraPinholeRadial param, FMatrixRMaj rectify) {
Point2Transform2_F32 add_p_to_p = narrow(param).distort_F32(true, true);
FMatrixRMaj rectifyInv = new FMatrixRMaj(3, 3);
CommonOps_FDRM.invert(rectify, rectifyInv);
PointTransformHomography_F32 removeRect = new PointTransformHomography_F32(rectifyInv);
return new SequencePoint2Transform2_F32(removeRect, add_p_to_p);
}
use of boofcv.struct.distort.Point2Transform2_F32 in project BoofCV by lessthanoptimal.
the class ImplRectifyImageOps_F32 method allInsideLeft.
public static void allInsideLeft(CameraPinholeRadial paramLeft, FMatrixRMaj rectifyLeft, FMatrixRMaj rectifyRight, FMatrixRMaj rectifyK) {
// need to take in account the order in which image distort will remove rectification later on
paramLeft = new CameraPinholeRadial(paramLeft);
Point2Transform2_F32 tranLeft = transformPixelToRect(paramLeft, rectifyLeft);
RectangleLength2D_F32 bound = LensDistortionOps.boundBoxInside(paramLeft.width, paramLeft.height, new PointToPixelTransform_F32(tranLeft));
LensDistortionOps.roundInside(bound);
float scaleX = paramLeft.width / (float) bound.width;
float scaleY = paramLeft.height / (float) bound.height;
float scale = (float) Math.max(scaleX, scaleY);
adjustCalibrated(rectifyLeft, rectifyRight, rectifyK, bound, scale);
}
use of boofcv.struct.distort.Point2Transform2_F32 in project BoofCV by lessthanoptimal.
the class SfmTestHelper method renderPointPixel.
/**
* Renders a 3D point in the left and right camera views given the stereo parameters. Lens distortion
* is taken in account.
*
* @param param Stereo parameters
* @param X Point location in 3D space
* @param left location in pixels in left camera
* @param right location in pixels in right camera
*/
public static void renderPointPixel(StereoParameters param, Point3D_F64 X, Point2D_F64 left, Point2D_F64 right) {
// compute the location of X in the right camera's reference frame
Point3D_F64 rightX = new Point3D_F64();
SePointOps_F64.transform(param.getRightToLeft().invert(null), X, rightX);
// location of object in normalized image coordinates
Point2D_F64 normLeft = new Point2D_F64(X.x / X.z, X.y / X.z);
Point2D_F64 normRight = new Point2D_F64(rightX.x / rightX.z, rightX.y / rightX.z);
// convert into pixel coordinates
Point2D_F64 pixelLeft = PerspectiveOps.convertNormToPixel(param.left, normLeft.x, normLeft.y, null);
Point2D_F64 pixelRight = PerspectiveOps.convertNormToPixel(param.right, normRight.x, normRight.y, null);
// take in account lens distortion
Point2Transform2_F32 distLeft = LensDistortionOps.narrow(param.left).distort_F32(true, true);
Point2Transform2_F32 distRight = LensDistortionOps.narrow(param.right).distort_F32(true, true);
Point2D_F32 lensLeft = new Point2D_F32();
Point2D_F32 lensRight = new Point2D_F32();
distLeft.compute((float) pixelLeft.x, (float) pixelLeft.y, lensLeft);
distRight.compute((float) pixelRight.x, (float) pixelRight.y, lensRight);
// output solution
left.set(lensLeft.x, lensLeft.y);
right.set(lensRight.x, lensRight.y);
}
Aggregations