use of boofcv.alg.distort.radtan.LensDistortionRadialTangential in project BoofCV by lessthanoptimal.
the class TestSquareBinary_to_FiducialDetector method loadDistortion.
@Override
public LensDistortionNarrowFOV loadDistortion(boolean distorted) {
CameraPinholeRadial model = CalibrationIO.load(getClass().getResource("intrinsic_binary.yaml"));
if (!distorted) {
model.radial = null;
model.t1 = model.t2 = 0;
}
return new LensDistortionRadialTangential(model);
}
use of boofcv.alg.distort.radtan.LensDistortionRadialTangential in project BoofCV by lessthanoptimal.
the class TestSquareImage_to_FiducialDetector method loadDistortion.
@Override
public LensDistortionNarrowFOV loadDistortion(boolean distorted) {
CameraPinholeRadial model = CalibrationIO.load(getClass().getResource("intrinsic_image.yaml"));
if (!distorted) {
model.radial = null;
model.t1 = model.t2 = 0;
}
return new LensDistortionRadialTangential(model);
}
use of boofcv.alg.distort.radtan.LensDistortionRadialTangential in project BoofCV by lessthanoptimal.
the class SimulatePlanarWorld method setCamera.
public void setCamera(CameraPinholeRadial model) {
output.reshape(model.width, model.height);
depthMap.reshape(model.width, model.height);
LensDistortionNarrowFOV factory = new LensDistortionRadialTangential(model);
pixelTo3 = new NarrowPixelToSphere_F64(factory.undistort_F64(true, false));
sphereToPixel = new SphereToNarrowPixel_F64(factory.distort_F64(false, true));
computeProjectionTable(model);
}
use of boofcv.alg.distort.radtan.LensDistortionRadialTangential in project BoofCV by lessthanoptimal.
the class FiducialDetection method process.
private void process() {
if (detector == null) {
System.err.println("Need to specify which fiducial you wish to detect");
System.exit(1);
}
if (outputPath != null) {
try {
outputFile = new PrintStream(outputPath);
outputFile.println("# Results from fiducial detection ");
outputFile.println("# These comments should include the data source and the algorithm used, but I'm busy.");
outputFile.println("# ");
outputFile.println("# <frame #> <number of fiducials> <fiducial id> <X> <Y> <Z> <Q1> <Q2> <Q3> <Q4> ...");
outputFile.println("# ");
outputFile.println("# The special Euclidean transform saved each fiducial is from fiducial to camera");
outputFile.println("# (X,Y,Z) is the translation and (Q1,Q2,Q3,Q4) specifies a quaternion");
outputFile.println("# ");
} catch (FileNotFoundException e) {
System.err.println("Failed to open output file.");
System.err.println(e.getMessage());
System.exit(1);
}
}
MediaManager media = DefaultMediaManager.INSTANCE;
CameraPinholeRadial intrinsic = intrinsicPath == null ? null : (CameraPinholeRadial) CalibrationIO.load(intrinsicPath);
SimpleImageSequence<GrayU8> sequence = null;
long pause = 0;
BufferedImage buffered = null;
if (inputType == InputType.VIDEO || inputType == InputType.WEBCAM) {
if (inputType == InputType.WEBCAM) {
String device = getCameraDeviceString();
sequence = media.openCamera(device, desiredWidth, desiredHeight, ImageType.single(GrayU8.class));
} else {
// just assume 30ms is appropriate. Should let the use specify this number
pause = 30;
sequence = media.openVideo(filePath, ImageType.single(GrayU8.class));
sequence.setLoop(true);
}
intrinsic = handleIntrinsic(intrinsic, sequence.getNextWidth(), sequence.getNextHeight());
} else {
buffered = UtilImageIO.loadImage(filePath);
if (buffered == null) {
System.err.println("Can't find image or it can't be read. " + filePath);
System.exit(1);
}
intrinsic = handleIntrinsic(intrinsic, buffered.getWidth(), buffered.getHeight());
}
ImagePanel gui = new ImagePanel();
gui.setPreferredSize(new Dimension(intrinsic.width, intrinsic.height));
ShowImages.showWindow(gui, "Fiducial Detector", true);
detector.setLensDistortion(new LensDistortionRadialTangential(intrinsic), intrinsic.width, intrinsic.height);
if (sequence != null) {
processStream(intrinsic, sequence, gui, pause);
} else {
processImage(intrinsic, buffered, gui);
}
}
use of boofcv.alg.distort.radtan.LensDistortionRadialTangential in project BoofCV by lessthanoptimal.
the class PinholeRadialToEquirectangular_F64 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_F64 pixelToNormalized = new LensDistortionRadialTangential(pinhole).undistort_F64(true, false);
Point2D_F64 norm = new Point2D_F64();
for (int pixelY = 0; pixelY < pinhole.height; pixelY++) {
for (int pixelX = 0; pixelX < pinhole.width; pixelX++) {
pixelToNormalized.compute(pixelX, pixelY, norm);
Point3D_F64 v = vectors[pixelY * pinhole.width + pixelX];
v.set(norm.x, norm.y, 1);
}
}
}
Aggregations