use of boofcv.struct.distort.Point2Transform2_F64 in project BoofCV by lessthanoptimal.
the class VideoSequenceSimulator method createSquares.
protected void createSquares(int total, double minZ, double maxZ) {
squares.clear();
double t = 0.1;
Point2D_F64 n = new Point2D_F64();
Point2Transform2_F64 tranNorm = LensDistortionOps.narrow(intrinsic).undistort_F64(true, false);
for (int i = 0; i < total; i++) {
// generate the squares uniformally inside the FOV
tranNorm.compute(rand.nextDouble() * (intrinsic.width - 1), rand.nextDouble() * (intrinsic.height - 1), n);
double z = rand.nextDouble() * (maxZ - minZ) + minZ;
double x = n.x * z;
double y = n.y * z;
Square s = new Square();
s.a.set(x, y, z);
s.b.set(x + t, y, z);
s.c.set(x + t, y + t, z);
s.d.set(x, y + t, z);
s.gray = rand.nextInt(200) + 55;
squares.add(s);
}
// sort by depth so that objects farther way are rendered first and obstructed by objects closer in view
Collections.sort(squares, new Comparator<Square>() {
@Override
public int compare(Square o1, Square o2) {
if (o1.a.z < o2.a.z)
return -1;
if (o1.a.z > o2.a.z)
return 1;
else
return 0;
}
});
}
use of boofcv.struct.distort.Point2Transform2_F64 in project BoofCV by lessthanoptimal.
the class ImplRectifyImageOps_F64 method transformPixelToRectNorm.
public static Point2Transform2_F64 transformPixelToRectNorm(CameraPinholeRadial param, DMatrixRMaj rectify, DMatrixRMaj rectifyK) {
if (rectifyK.get(0, 1) != 0)
throw new IllegalArgumentException("Skew should be zero in rectified images");
Point2Transform2_F64 remove_p_to_p = narrow(param).undistort_F64(true, true);
PointTransformHomography_F64 rectifyDistort = new PointTransformHomography_F64(rectify);
PinholePtoN_F64 pixelToNorm = new PinholePtoN_F64();
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_F64(remove_p_to_p, rectifyDistort, pixelToNorm);
}
use of boofcv.struct.distort.Point2Transform2_F64 in project BoofCV by lessthanoptimal.
the class ImplRectifyImageOps_F64 method fullViewLeft.
public static void fullViewLeft(CameraPinholeRadial paramLeft, DMatrixRMaj rectifyLeft, DMatrixRMaj rectifyRight, DMatrixRMaj rectifyK) {
// need to take in account the order in which image distort will remove rectification later on
paramLeft = new CameraPinholeRadial(paramLeft);
Point2Transform2_F64 tranLeft = transformPixelToRect(paramLeft, rectifyLeft);
RectangleLength2D_F64 bound = DistortImageOps.boundBox_F64(paramLeft.width, paramLeft.height, new PointToPixelTransform_F64(tranLeft));
double scaleX = paramLeft.width / bound.width;
double scaleY = paramLeft.height / bound.height;
double scale = Math.min(scaleX, scaleY);
adjustCalibrated(rectifyLeft, rectifyRight, rectifyK, bound, scale);
}
use of boofcv.struct.distort.Point2Transform2_F64 in project BoofCV by lessthanoptimal.
the class ImplRectifyImageOps_F64 method allInsideLeft.
public static void allInsideLeft(CameraPinholeRadial paramLeft, DMatrixRMaj rectifyLeft, DMatrixRMaj rectifyRight, DMatrixRMaj rectifyK) {
// need to take in account the order in which image distort will remove rectification later on
paramLeft = new CameraPinholeRadial(paramLeft);
Point2Transform2_F64 tranLeft = transformPixelToRect(paramLeft, rectifyLeft);
RectangleLength2D_F64 bound = LensDistortionOps.boundBoxInside(paramLeft.width, paramLeft.height, new PointToPixelTransform_F64(tranLeft));
LensDistortionOps.roundInside(bound);
double scaleX = paramLeft.width / (double) bound.width;
double scaleY = paramLeft.height / (double) bound.height;
double scale = Math.max(scaleX, scaleY);
adjustCalibrated(rectifyLeft, rectifyRight, rectifyK, bound, scale);
}
use of boofcv.struct.distort.Point2Transform2_F64 in project BoofCV by lessthanoptimal.
the class ImplRectifyImageOps_F64 method fullViewLeft.
public static void fullViewLeft(int imageWidth, int imageHeight, DMatrixRMaj rectifyLeft, DMatrixRMaj rectifyRight) {
Point2Transform2_F64 tranLeft = new PointTransformHomography_F64(rectifyLeft);
RectangleLength2D_F64 bound = DistortImageOps.boundBox_F64(imageWidth, imageHeight, new PointToPixelTransform_F64(tranLeft));
double scaleX = imageWidth / bound.width;
double scaleY = imageHeight / bound.height;
double scale = Math.min(scaleX, scaleY);
adjustUncalibrated(rectifyLeft, rectifyRight, bound, scale);
}
Aggregations