use of boofcv.struct.calib.CameraPinholeBrown in project BoofCV by lessthanoptimal.
the class RemoveLensDistortionApp method openFile.
@Override
public void openFile(File file) {
File[] candidates = new File[] { new File(file.getParent(), "intrinsic.yaml"), // this is a bit of a hack...
new File(file.getParent(), "intrinsicLeft.yaml"), new File(file.getParent(), file.getName() + ".yaml") };
CameraPinholeBrown model = null;
for (File c : candidates) {
try {
model = CalibrationIO.load(UtilIO.ensureURL(c.getPath()));
break;
} catch (RuntimeException ignore) {
}
}
if (model == null) {
System.err.println("Can't find camera model for this image");
return;
}
this.param = model;
super.openFile(file);
}
use of boofcv.struct.calib.CameraPinholeBrown in project BoofCV by lessthanoptimal.
the class TestCameraToEquirectangular_F64 method canonicalIsPointedPositiveZ.
/**
* Makes sure the canonical orientation is pointed along the positive z axis. This is done by projecting
* the center of the pinhole at default orientation.
*/
@Test
void canonicalIsPointedPositiveZ() {
CameraPinholeBrown intrinsic = new CameraPinholeBrown(400, 400, 0, imgWidth / 2, imgHeight / 2, imgWidth, imgHeight);
intrinsic.setRadial(0.1, 0.2);
CameraToEquirectangular_F64 alg = new CameraToEquirectangular_F64();
alg.setCameraModel(intrinsic);
alg.setEquirectangularShape(equiWidth, equiHeight);
assertPointing(alg, imgWidth / 2, imgHeight / 2, 0, 0, 1);
}
use of boofcv.struct.calib.CameraPinholeBrown in project BoofCV by lessthanoptimal.
the class TestLensDistortionOps_F64 method transformChangeModel_EXPAND_modified.
/**
* Sees if the adjusted intrinsic parameters is correct but computing normalized image coordinates first
* with the original distorted image and then with the adjusted undistorted image.
*/
@Test
void transformChangeModel_EXPAND_modified() {
// distorted pixel in original image
double pixelX = 12.5, pixelY = height - 3;
CameraPinholeBrown orig = new CameraPinholeBrown().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 0.05);
CameraPinhole desired = new CameraPinhole(orig);
Point2Transform2_F64 distToNorm = LensDistortionFactory.narrow(orig).undistort_F64(true, false);
Point2D_F64 norm = new Point2D_F64();
distToNorm.compute(pixelX, pixelY, norm);
CameraPinholeBrown adjusted = new CameraPinholeBrown();
Point2Transform2_F64 distToAdj = LensDistortionOps_F64.transformChangeModel(AdjustmentType.EXPAND, orig, desired, false, adjusted);
Point2D_F64 adjPixel = new Point2D_F64();
Point2D_F64 normFound = new Point2D_F64();
distToAdj.compute(pixelX, pixelY, adjPixel);
PerspectiveOps.convertPixelToNorm(adjusted, adjPixel, normFound);
// see if the normalized image coordinates are the same
assertEquals(norm.x, normFound.x, 1e-3);
assertEquals(norm.y, normFound.y, 1e-3);
}
use of boofcv.struct.calib.CameraPinholeBrown in project BoofCV by lessthanoptimal.
the class TestLensDistortionOps_F64 method transformChangeModel_FULLVIEW_modified.
/**
* Checks to see if the returned modified model is correct
*/
@Test
void transformChangeModel_FULLVIEW_modified() {
// distorted pixel in original image
double pixelX = 12.5, pixelY = height - 3;
CameraPinholeBrown orig = new CameraPinholeBrown().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 0.05);
CameraPinhole desired = new CameraPinhole(orig);
Point2Transform2_F64 distToNorm = LensDistortionFactory.narrow(orig).undistort_F64(true, false);
Point2D_F64 norm = new Point2D_F64();
distToNorm.compute(pixelX, pixelY, norm);
CameraPinholeBrown adjusted = new CameraPinholeBrown();
Point2Transform2_F64 distToAdj = LensDistortionOps_F64.transformChangeModel(AdjustmentType.FULL_VIEW, orig, desired, false, adjusted);
Point2D_F64 adjPixel = new Point2D_F64();
Point2D_F64 normFound = new Point2D_F64();
distToAdj.compute(pixelX, pixelY, adjPixel);
PerspectiveOps.convertPixelToNorm(adjusted, adjPixel, normFound);
// see if the normalized image coordinates are the same
assertEquals(norm.x, normFound.x, 1e-3);
assertEquals(norm.y, normFound.y, 1e-3);
}
use of boofcv.struct.calib.CameraPinholeBrown in project BoofCV by lessthanoptimal.
the class TestLensDistortionOps_F64 method transformChangeModel_FULLVIEW.
/**
* Checks the border of the returned transform. Makes sure that the entire original image is visible.
* Also makes sure that the requested inverse transform is actually the inverse.
*/
@Test
void transformChangeModel_FULLVIEW() {
CameraPinholeBrown param = new CameraPinholeBrown().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 0.05);
CameraPinhole desired = new CameraPinhole(param);
Point2Transform2_F64 adjToDist = LensDistortionOps_F64.transformChangeModel(AdjustmentType.FULL_VIEW, param, desired, true, null);
Point2Transform2_F64 distToAdj = LensDistortionOps_F64.transformChangeModel(AdjustmentType.FULL_VIEW, param, desired, false, null);
checkBorderOutside(adjToDist, distToAdj);
param = new CameraPinholeBrown().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(-0.1, -0.05);
desired = new CameraPinhole(param);
adjToDist = LensDistortionOps_F64.transformChangeModel(AdjustmentType.FULL_VIEW, param, desired, true, null);
distToAdj = LensDistortionOps_F64.transformChangeModel(AdjustmentType.FULL_VIEW, param, desired, false, null);
checkBorderOutside(adjToDist, distToAdj);
}
Aggregations