Search in sources :

Example 41 with ImageBase

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);
            }
        }
    }
}
Also used : ImageBase(boofcv.struct.image.ImageBase)

Example 42 with ImageBase

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);
            }
        }
    }
}
Also used : ImageBase(boofcv.struct.image.ImageBase)

Example 43 with ImageBase

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;
}
Also used : ImageBase(boofcv.struct.image.ImageBase)

Example 44 with ImageBase

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);
    }
}
Also used : ImageBase(boofcv.struct.image.ImageBase) ImageType(boofcv.struct.image.ImageType) Test(org.junit.Test)

Example 45 with ImageBase

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());
}
Also used : JCodecSimplified(boofcv.io.jcodec.JCodecSimplified) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) ImageBase(boofcv.struct.image.ImageBase) ImageType(boofcv.struct.image.ImageType) ImagePanel(boofcv.gui.image.ImagePanel)

Aggregations

ImageBase (boofcv.struct.image.ImageBase)54 ImageType (boofcv.struct.image.ImageType)14 Test (org.junit.Test)13 Se3_F64 (georegression.struct.se.Se3_F64)5 BufferedImage (java.awt.image.BufferedImage)5 SimpleImageSequence (boofcv.io.image.SimpleImageSequence)4 GrayU8 (boofcv.struct.image.GrayU8)4 MediaManager (boofcv.io.MediaManager)3 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)3 DefaultMediaManager (boofcv.io.wrapper.DefaultMediaManager)3 KernelBase (boofcv.struct.convolve.KernelBase)3 Point2D_F64 (georegression.struct.point.Point2D_F64)3 ConfigBackgroundBasic (boofcv.factory.background.ConfigBackgroundBasic)2 ConfigBackgroundGmm (boofcv.factory.background.ConfigBackgroundGmm)2 ImageGridPanel (boofcv.gui.image.ImageGridPanel)2 ImagePanel (boofcv.gui.image.ImagePanel)2 GrayF32 (boofcv.struct.image.GrayF32)2 Planar (boofcv.struct.image.Planar)2 File (java.io.File)2 FDistort (boofcv.abst.distort.FDistort)1