use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class TestMultiCameraToEquirectangular method addCamera_implicit_mask.
@Test
public void addCamera_implicit_mask() {
MultiCameraToEquirectangular<GrayF32> alg = createAlgorithm();
alg.addCamera(new Se3_F32(), new HelperDistortion(), inputWidth, inputHeight);
MultiCameraToEquirectangular.Camera c = alg.cameras.get(0);
// should be masked off by the passed in mask and because values are repeated
int correct = 0;
for (int y = 0; y < inputHeight; y++) {
for (int x = 0; x < inputWidth; x++) {
if (y < inputHeight / 2 && c.mask.get(x, y) > 0) {
correct++;
}
}
}
double found = Math.abs(1.0 - correct / (inputWidth * inputHeight / 2.0));
assertTrue(found <= 0.05);
}
use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class TestDataManipulationOps method normalize.
@Test
public void normalize() {
GrayF32 original = new GrayF32(30, 20);
GImageMiscOps.fillUniform(original, rand, -1, 1);
GrayF32 expected = original.createSameShape();
GrayF32 found = original.clone();
float mean = 4.5f;
float stdev = 1.2f;
PixelMath.minus(original, mean, expected);
PixelMath.divide(expected, stdev, expected);
DataManipulationOps.normalize(found, mean, stdev);
BoofTesting.assertEquals(expected, found, GrlConstants.TEST_F64);
}
use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class TestDataManipulationOps method imageToTensor_fail.
@Test
public void imageToTensor_fail() {
Planar<GrayF32> image = new Planar<>(GrayF32.class, 30, 25, 2);
try {
DataManipulationOps.imageToTensor(image, new Tensor_F32(2, 25, 30), 0);
fail("expected exception");
} catch (RuntimeException ignore) {
}
try {
DataManipulationOps.imageToTensor(image, new Tensor_F32(0, 3, 25, 30), 0);
fail("expected exception");
} catch (RuntimeException ignore) {
}
try {
DataManipulationOps.imageToTensor(image, new Tensor_F32(1, 2, 26, 30), 0);
fail("expected exception");
} catch (RuntimeException ignore) {
}
try {
DataManipulationOps.imageToTensor(image, new Tensor_F32(1, 2, 25, 31), 0);
fail("expected exception");
} catch (RuntimeException ignore) {
}
}
use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class TestImageClassifierVggCifar10 method createClassifier.
@Override
public BaseImageClassifier createClassifier() {
ImageClassifierVggCifar10 alg = new ImageClassifierVggCifar10();
alg.stats = new YuvStatistics();
alg.stats.meanU = 120;
alg.stats.stdevU = 25;
alg.stats.meanV = 40;
alg.stats.stdevV = 10;
alg.stats.kernel = new double[] { 0.1, 0.5, 0.1 };
alg.stats.kernelOffset = 1;
alg.localNorm = new ImageLocalNormalization<>(GrayF32.class, BorderType.EXTENDED);
alg.kernel = DataManipulationOps.create1D_F32(alg.stats.kernel);
return alg;
}
use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class CalibrateStereoPlanarGuiApp method process.
public void process(String outputFileName) {
// displays progress so the impatient don't give up
final ProcessThread monitor = new ProcessThread();
monitor.start();
// load images
calibrator.reset();
int N = leftImages.size();
for (int i = 0; i < N; i++) {
final BufferedImage leftOrig = media.openImage(leftImages.get(i).getPath());
final BufferedImage rightOrig = media.openImage(rightImages.get(i).getPath());
if (leftOrig != null && rightOrig != null) {
GrayF32 leftInput = ConvertBufferedImage.convertFrom(leftOrig, (GrayF32) null);
GrayF32 rightInput = ConvertBufferedImage.convertFrom(rightOrig, (GrayF32) null);
CalibrationObservation calibLeft, calibRight;
if (!detector.process(leftInput)) {
System.out.println("Feature detection failed in " + leftImages.get(i));
continue;
}
calibLeft = detector.getDetectedPoints();
if (!detector.process(rightInput)) {
System.out.println("Feature detection failed in " + rightImages.get(i));
continue;
}
calibRight = detector.getDetectedPoints();
calibrator.addPair(calibLeft, calibRight);
final int number = i;
SwingUtilities.invokeLater(() -> {
gui.addPair("Image " + number, leftImages.get(number), rightImages.get(number));
gui.repaint();
monitor.setMessage(0, "Image " + number);
});
} else {
System.out.println("Failed to load left = " + leftImages.get(i));
System.out.println("Failed to load right = " + rightImages.get(i));
}
}
// SwingUtilities.invokeLater(new Runnable() {
// public void run() {
// gui.setObservations(calibrator.getCalibLeft().getObservations(),calibrator.getCalibLeft().getErrors(),
// calibrator.getCalibRight().getObservations(),calibrator.getCalibRight().getErrors());
// }});
// gui.repaint();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
monitor.setMessage(1, "Estimating Parameters");
}
});
StereoParameters param = calibrator.process();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
gui.setObservations(calibrator.getCalibLeft().getObservations(), calibrator.getCalibLeft().getErrors(), calibrator.getCalibRight().getObservations(), calibrator.getCalibRight().getErrors());
}
});
gui.repaint();
// compute stereo rectification
setRectification(param);
monitor.stopThread();
calibrator.printStatistics();
param.print();
if (outputFileName != null)
CalibrationIO.save(param, outputFileName);
}
Aggregations