use of boofcv.struct.calib.StereoParameters in project BoofCV by lessthanoptimal.
the class TestStereoVisualOdometryScaleInput method setCalibration.
@Test
public void setCalibration() {
StereoParameters p = createStereoParam();
Dummy dummy = new Dummy();
StereoVisualOdometryScaleInput<GrayF32> alg = new StereoVisualOdometryScaleInput<>(dummy, 0.5);
alg.setCalibration(p);
assertEquals(320, parameters.left.width);
assertEquals(320, parameters.right.width);
assertEquals(160, parameters.left.height);
assertEquals(160, parameters.right.height);
}
use of boofcv.struct.calib.StereoParameters in project BoofCV by lessthanoptimal.
the class TestStereoVisualOdometryScaleInput method createStereoParam.
public StereoParameters createStereoParam() {
StereoParameters ret = new StereoParameters();
ret.setRightToLeft(new Se3_F64());
ret.getRightToLeft().getT().set(-0.2, 0.001, -0.012);
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.001, -0.01, 0.0023, ret.getRightToLeft().getR());
ret.left = new CameraPinholeRadial(200, 201, 0, width / 2, height / 2, width, height).fsetRadial(0, 0);
ret.right = new CameraPinholeRadial(199, 200, 0, width / 2 + 2, height / 2 - 6, width, height).fsetRadial(0, 0);
return ret;
}
use of boofcv.struct.calib.StereoParameters in project BoofCV by lessthanoptimal.
the class VisualizeStereoDisparity method changeInputScale.
@Override
public synchronized void changeInputScale() {
calib = new StereoParameters(origCalib);
double scale = control.inputScale;
PerspectiveOps.scaleIntrinsic(calib.left, scale);
PerspectiveOps.scaleIntrinsic(calib.right, scale);
int w = (int) (origLeft.getWidth() * scale);
int h = (int) (origLeft.getHeight() * scale);
colorLeft = new BufferedImage(w, h, BufferedImage.TYPE_INT_BGR);
colorRight = new BufferedImage(w, h, BufferedImage.TYPE_INT_BGR);
colorLeft.createGraphics().drawImage(origLeft, AffineTransform.getScaleInstance(scale, scale), null);
colorRight.createGraphics().drawImage(origRight, AffineTransform.getScaleInstance(scale, scale), null);
activeAlg = createAlg();
inputLeft = GeneralizedImageOps.createSingleBand(activeAlg.getInputType(), w, h);
inputRight = GeneralizedImageOps.createSingleBand(activeAlg.getInputType(), w, h);
rectLeft = GeneralizedImageOps.createSingleBand(activeAlg.getInputType(), w, h);
rectRight = GeneralizedImageOps.createSingleBand(activeAlg.getInputType(), w, h);
ConvertBufferedImage.convertFrom(colorLeft, inputLeft, true);
ConvertBufferedImage.convertFrom(colorRight, inputRight, true);
rectifyInputImages();
doRefreshAll();
}
use of boofcv.struct.calib.StereoParameters in project BoofCV by lessthanoptimal.
the class ShowRectifyCalibratedApp method changeInput.
@Override
public void changeInput(String name, int index) {
PathLabel refs = inputRefs.get(index);
StereoParameters param = CalibrationIO.load(media.openFile(refs.getPath(0)));
BufferedImage origLeft = media.openImage(refs.getPath(1));
BufferedImage origRight = media.openImage(refs.getPath(2));
configure(origLeft, origRight, param);
}
use of boofcv.struct.calib.StereoParameters in project BoofCV by lessthanoptimal.
the class ExampleVisualOdometryStereo method main.
public static void main(String[] args) {
MediaManager media = DefaultMediaManager.INSTANCE;
String directory = UtilIO.pathExample("vo/backyard/");
// load camera description and the video sequence
StereoParameters stereoParam = CalibrationIO.load(media.openFile(directory + "stereo.yaml"));
SimpleImageSequence<GrayU8> video1 = media.openVideo(directory + "left.mjpeg", ImageType.single(GrayU8.class));
SimpleImageSequence<GrayU8> video2 = media.openVideo(directory + "right.mjpeg", ImageType.single(GrayU8.class));
// specify how the image features are going to be tracked
PkltConfig configKlt = new PkltConfig();
configKlt.pyramidScaling = new int[] { 1, 2, 4, 8 };
configKlt.templateRadius = 3;
PointTrackerTwoPass<GrayU8> tracker = FactoryPointTrackerTwoPass.klt(configKlt, new ConfigGeneralDetector(600, 3, 1), GrayU8.class, GrayS16.class);
// computes the depth of each point
StereoDisparitySparse<GrayU8> disparity = FactoryStereoDisparity.regionSparseWta(0, 150, 3, 3, 30, -1, true, GrayU8.class);
// declares the algorithm
StereoVisualOdometry<GrayU8> visualOdometry = FactoryVisualOdometry.stereoDepth(1.5, 120, 2, 200, 50, true, disparity, tracker, GrayU8.class);
// Pass in intrinsic/extrinsic calibration. This can be changed in the future.
visualOdometry.setCalibration(stereoParam);
// Process the video sequence and output the location plus number of inliers
while (video1.hasNext()) {
GrayU8 left = video1.next();
GrayU8 right = video2.next();
if (!visualOdometry.process(left, right)) {
throw new RuntimeException("VO Failed!");
}
Se3_F64 leftToWorld = visualOdometry.getCameraToWorld();
Vector3D_F64 T = leftToWorld.getT();
System.out.printf("Location %8.2f %8.2f %8.2f inliers %s\n", T.x, T.y, T.z, inlierPercent(visualOdometry));
}
}
Aggregations