Package boofcv

Class BoofTesting

java.lang.Object
boofcv.BoofTesting

public class BoofTesting
extends Object
Functions to aid in unit testing code for correctly handling sub-images
  • Field Details

  • Constructor Details

    • BoofTesting

      public BoofTesting()
  • Method Details

    • createRandom

      public static Random createRandom​(long offset)
      Creates Random but using a fixed seed with an offset. The idea if we want to test to see if a test is brittle we can do that across the project by changing the base seed.
      Parameters:
      offset - Value added to base seed.
      Returns:
      Random
    • tolerance

      public static double tolerance​(ImageDataType type)
      Recommended tolerance by image data type. Useful when processing images but the type isn't known at compile time.
    • convertToGenericType

      @Nullable public static <T> T convertToGenericType​(@Nullable @Nullable Class<?> type)
    • convertToGenericType

      public static ImageDataType convertToGenericType​(ImageDataType type)
    • assertEqualsToScaleS

      public static void assertEqualsToScaleS​(Se3_F64 expected, Se3_F64 found, double tolAngle, double tolT)
      Checks to see if the two transforms are equal up to a scale factor. Rotation is tested using a single angle and translation using magnitude. NOTE: The direction of the translation is NOT considered part of the sign ambiguity in this came.
      Parameters:
      expected - the expected transform
      found - the found transform
      tolAngle - radians
      tolT - fractional error tolernace
    • assertEqualsToScale

      public static void assertEqualsToScale​(Se3_F64 expected, Se3_F64 found, double tolAngle, double tolT)
      Checks to see if the two transforms are equal up to a scale factor. Rotation is tested using a single angle and translation using magnitude. NOTE: Scale ambiguity also includes sign ambiguity for translation.
      Parameters:
      expected - the expected transform
      found - the found transform
      tolAngle - radians
      tolT - fractional error tolernace
    • assertEquals

      public static void assertEquals​(Se3_F64 expected, Se3_F64 found, double tolAngle, double tolT)
    • createSubImageOf

      public static <T extends ImageBase<T>> T createSubImageOf​(T input)

      Returns an image which is a sub-image but contains the same values of the input image. Use for testing compliance with sub-images. The subimage is created by creating a larger image, copying over the input image into the inner portion, then creating a subimage of the copied part.

    • createSubImageOf_S

      public static <T extends ImageGray<T>> T createSubImageOf_S​(T input)
    • createSubImageOf_I

      public static <T extends ImageInterleaved<T>> T createSubImageOf_I​(T input)
    • createSubImageOf_PL

      public static <T extends Planar> T createSubImageOf_PL​(T input)
    • checkImageDimensionValidation

      public static void checkImageDimensionValidation​(Object testClass, int numFunctions)
      Searches for functions that accept only images and makes sure they only accept images which have he same width and height.
      Parameters:
      testClass - Instance of the class being tested
    • checkImageDimensionReshape

      public static void checkImageDimensionReshape​(Object testClass, int numFunctions)
      Searches for functions that accept only images and makes sure they only accept images which have he same width and height.
      Parameters:
      testClass - Instance of the class being tested
    • checkSubImage

      public static void checkSubImage​(Object testClass, String function, boolean checkEquals, Object... inputParam)
      Tests the specified function with the original image provided and with an equivalent sub-image. The two results are then compared. The function being tested must only have one input parameter of type GrayU8.
      Parameters:
      testClass - Instance of the class that contains the function being tested.
      function - The name of the function being tested.
      checkEquals - Checks to see if the two images have been modified the same way on output
      inputParam - The original input parameters
    • findMethod

      public static Method findMethod​(Class<?> type, String name, Class<?>... params)
      Searches for a function which is a perfect match. if none it exists it checks to see if any matches that could accept an input of the specified type. If there is only one such match that is returned.
    • callStaticMethod

      public static void callStaticMethod​(Class<?> classType, String name, Object... inputs)
      Looks up the static method then passes in the specified inputs.
    • findMethodThenCall

      public static int findMethodThenCall​(Object owner, String ownerMethod, Class target, String targetMethod)
      Searches for all functions with the specified name in the target class. Once it finds that function it invokes the specified function in the owner class. That function must take in a Method as its one and only parameter. The method will be one of the matching ones in the target class.
      Returns:
      The number of times 'targetMethod' was found and called.
    • assertEquals

      public static void assertEquals​(double[] a, double[] b, double tol)
    • assertEquals

      public static void assertEquals​(double[] a, float[] b, double tol)
    • assertEquals

      public static void assertEquals​(double[] a, int[] b)
    • assertEquals

      public static void assertEquals​(byte[] a, byte[] b)
    • assertEquals

      public static void assertEquals​(short[] a, short[] b)
    • assertEquals

      public static void assertEquals​(int[] a, int[] b)
    • assertEquals

      public static void assertEquals​(long[] a, long[] b)
    • assertEquals

      public static void assertEquals​(float[] a, float[] b, float tol)
    • assertEquals

      public static void assertEquals​(ImageBase imgA, ImageBase imgB, double tol)
    • assertEqualsInner

      public static void assertEqualsInner​(ImageBase imgA, ImageBase imgB, double tol, int borderX, int borderY, boolean relative)
    • assertEqualsInner

      public static void assertEqualsInner​(ImageBase imgA, ImageBase imgB, double tol, int borderX0, int borderY0, int borderX1, int borderY1, boolean relative)
    • assertEqualsRelative

      public static void assertEqualsRelative​(ImageBase imgA, ImageBase imgB, double tolFrac)
    • assertEqualsBorder

      public static void assertEqualsBorder​(ImageBase imgA, ImageBase imgB, double tol, int borderX, int borderY)
    • assertEqualsBorder

      public static void assertEqualsBorder​(ImageGray imgA, ImageGray imgB, double tol, int borderX, int borderY)
      Checks to see if only the image borders are equal to each other within tolerance
    • assertEqualsBorder

      public static void assertEqualsBorder​(ImageInterleaved imgA, ImageInterleaved imgB, double tol, int borderX, int borderY)
      Checks to see if only the image borders are equal to each other within tolerance
    • checkBorderZero

      public static void checkBorderZero​(ImageGray outputImage, int border)
    • checkBorderZero

      public static void checkBorderZero​(ImageGray outputImage, int borderX0, int borderY0, int borderX1, int borderY1)
    • printDiff

      public static void printDiff​(ImageGray imgA, ImageGray imgB)
    • printDiffBinary

      public static void printDiffBinary​(GrayU8 imgA, GrayU8 imgB)
    • randomArray

      public static Object randomArray​(Class type, int length, Random rand)
    • pritiveToImageDataType

      public static ImageDataType pritiveToImageDataType​(Class type)
    • primitive

      public static Object primitive​(Object v, Class type)
    • createInstance

      public static Object createInstance​(Class<?> type)