use of boofcv.struct.image.ImageBase in project BoofCV by lessthanoptimal.
the class TestPixelMath method testAbs.
private void testAbs(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] paramTypes = m.getParameterTypes();
ImageBase inputA = GeneralizedImageOps.createImage(paramTypes[0], width, height, numBands);
ImageBase inputB = GeneralizedImageOps.createImage(paramTypes[1], width, height, numBands);
int numBands = inputA.getImageType().getNumBands();
if (inputA.getImageType().getDataType().isSigned()) {
GImageMiscOps.fillUniform(inputA, rand, -20, 20);
} else {
GImageMiscOps.fillUniform(inputA, rand, 0, 20);
}
m.invoke(null, inputA, inputB);
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
for (int k = 0; k < numBands; k++) {
double a = GeneralizedImageOps.get(inputA, j, i, k);
double b = GeneralizedImageOps.get(inputB, j, i, k);
assertEquals(Math.abs(a), b, 1e-4);
}
}
}
}
use of boofcv.struct.image.ImageBase in project BoofCV by lessthanoptimal.
the class TestPixelMath method testDiffAbs.
private void testDiffAbs(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] paramTypes = m.getParameterTypes();
ImageBase inputA = GeneralizedImageOps.createImage(paramTypes[0], width, height, numBands);
ImageBase inputB = GeneralizedImageOps.createImage(paramTypes[0], width, height, numBands);
ImageBase inputC = GeneralizedImageOps.createImage(paramTypes[0], width, height, numBands);
int numBands = inputA.getImageType().getNumBands();
if (inputA.getImageType().getDataType().isSigned()) {
GImageMiscOps.fillUniform(inputA, rand, -20, 20);
GImageMiscOps.fillUniform(inputB, rand, -20, 20);
} else {
GImageMiscOps.fillUniform(inputA, rand, 0, 20);
GImageMiscOps.fillUniform(inputB, rand, -20, 20);
}
m.invoke(null, inputA, inputB, inputC);
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
for (int k = 0; k < numBands; k++) {
double v = GeneralizedImageOps.get(inputA, j, i, k) - GeneralizedImageOps.get(inputB, j, i, k);
double valC = GeneralizedImageOps.get(inputC, j, i, k);
assertEquals(Math.abs(v), valC, 1e-4);
}
}
}
}
use of boofcv.struct.image.ImageBase in project BoofCV by lessthanoptimal.
the class TestGImageStatistics method createInputParam.
@Override
protected Object[][] createInputParam(Method candidate, Method validation) {
Class<?>[] param = validation.getParameterTypes();
String name = candidate.getName();
ImageBase inputA = GeneralizedImageOps.createImage((Class) param[0], width, height, numBands);
ImageBase inputB = null;
Object[][] ret = new Object[1][param.length];
if (name.equals("maxAbs")) {
ret[0][0] = inputA;
} else if (name.equals("max")) {
ret[0][0] = inputA;
} else if (name.equals("min")) {
ret[0][0] = inputA;
} else if (name.equals("sum")) {
ret[0][0] = inputA;
} else if (name.equals("mean")) {
ret[0][0] = inputA;
} else if (name.equals("variance")) {
ret[0][0] = inputA;
ret[0][1] = 3;
} else if (name.equals("meanDiffSq")) {
inputB = GeneralizedImageOps.createImage((Class) param[1], width, height, numBands);
ret[0][0] = inputA;
ret[0][1] = inputB;
} else if (name.equals("meanDiffAbs")) {
inputB = GeneralizedImageOps.createImage((Class) param[1], width, height, numBands);
ret[0][0] = inputA;
ret[0][1] = inputB;
} else if (name.equals("histogram")) {
int histogramSize = 10;
if (inputA.getImageType().getDataType().isSigned())
histogramSize += 11;
ret[0][0] = inputA;
ret[0][1] = -10;
ret[0][2] = new int[histogramSize];
}
fillRandom(inputA);
fillRandom(inputB);
return ret;
}
use of boofcv.struct.image.ImageBase in project BoofCV by lessthanoptimal.
the class GenericFiducialDetectorChecks method modifyInput.
/**
* Makes sure the input is not modified
*/
@Test
public void modifyInput() {
for (ImageType type : types) {
ImageBase image = loadImage(type);
ImageBase orig = image.clone();
FiducialDetector detector = createDetector(type);
detector.setLensDistortion(loadDistortion(true), image.width, image.height);
detector.detect(image);
BoofTesting.assertEquals(image, orig, 0);
}
}
use of boofcv.struct.image.ImageBase in project BoofCV by lessthanoptimal.
the class ExampleJCodecDisplayFrames method main.
public static void main(String[] args) {
String fileName = UtilIO.pathExample("background/highway_bridge_jitter.mp4");
ImageType type = ImageType.pl(3, GrayU8.class);
// ImageType type = ImageType.single(GrayU8.class);
// ImageType type = ImageType.pl(3, GrayF32.class);
// ImageType type = ImageType.single(GrayF32.class);
JCodecSimplified sequence = new JCodecSimplified<>(fileName, type);
BufferedImage out;
if (sequence.hasNext()) {
ImageBase frame = sequence.next();
out = new BufferedImage(frame.width, frame.height, BufferedImage.TYPE_INT_RGB);
ConvertBufferedImage.convertTo(frame, out, false);
} else {
throw new RuntimeException("No first frame?!?!");
}
ImagePanel gui = new ImagePanel(out);
ShowImages.showWindow(gui, "Video!", true);
long totalNano = 0;
while (sequence.hasNext()) {
long before = System.nanoTime();
ImageBase frame = sequence.next();
totalNano += System.nanoTime() - before;
ConvertBufferedImage.convertTo(frame, out, false);
gui.repaint();
try {
Thread.sleep(22);
} catch (InterruptedException e) {
}
}
System.out.println("Only read FPS = " + (totalNano / 1000000.0) / sequence.getFrameNumber());
}
Aggregations