Package boofcv.testing
Class BoofTesting
- java.lang.Object
-
- boofcv.testing.BoofTesting
-
public class BoofTesting extends java.lang.ObjectFunctions to aid in unit testing code for correctly handling sub-images
-
-
Field Summary
Fields Modifier and Type Field Description static longBASE_SEED
-
Constructor Summary
Constructors Constructor Description BoofTesting()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassertEquals(byte[] a, byte[] b)static voidassertEquals(double[] a, double[] b, double tol)static voidassertEquals(double[] a, float[] b, double tol)static voidassertEquals(double[] a, int[] b)static voidassertEquals(float[] a, float[] b, float tol)static voidassertEquals(int[] a, int[] b)static voidassertEquals(long[] a, long[] b)static voidassertEquals(short[] a, short[] b)static voidassertEquals(boofcv.struct.image.ImageBase imgA, boofcv.struct.image.ImageBase imgB, double tol)static voidassertEqualsBorder(boofcv.struct.image.ImageBase imgA, boofcv.struct.image.ImageBase imgB, double tol, int borderX, int borderY)static voidassertEqualsBorder(boofcv.struct.image.ImageGray imgA, boofcv.struct.image.ImageGray imgB, double tol, int borderX, int borderY)Checks to see if only the image borders are equal to each other within tolerancestatic voidassertEqualsBorder(boofcv.struct.image.ImageInterleaved imgA, boofcv.struct.image.ImageInterleaved imgB, double tol, int borderX, int borderY)Checks to see if only the image borders are equal to each other within tolerancestatic voidassertEqualsInner(boofcv.struct.image.ImageBase imgA, boofcv.struct.image.ImageBase imgB, double tol, int borderX, int borderY, boolean relative)static voidassertEqualsInner(boofcv.struct.image.ImageBase imgA, boofcv.struct.image.ImageBase imgB, double tol, int borderX0, int borderY0, int borderX1, int borderY1, boolean relative)static voidassertEqualsRelative(boofcv.struct.image.ImageBase imgA, boofcv.struct.image.ImageBase imgB, double tolFrac)static voidcallStaticMethod(java.lang.Class<?> classType, java.lang.String name, java.lang.Object... inputs)Looks up the static method then passes in the specified inputs.static voidcheckBorderZero(boofcv.struct.image.ImageGray outputImage, int border)static voidcheckBorderZero(boofcv.struct.image.ImageGray outputImage, int borderX0, int borderY0, int borderX1, int borderY1)static voidcheckImageDimensionReshape(java.lang.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.static voidcheckImageDimensionValidation(java.lang.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.static voidcheckSubImage(java.lang.Object testClass, java.lang.String function, boolean checkEquals, java.lang.Object... inputParam)Tests the specified function with the original image provided and with an equivalent sub-image.static boofcv.struct.image.ImageDataTypeconvertToGenericType(boofcv.struct.image.ImageDataType type)static <T> TconvertToGenericType(java.lang.Class<?> type)static java.lang.ObjectcreateInstance(java.lang.Class<?> type)static java.util.RandomcreateRandom(long offset)Creates Random but using a fixed seed with an offset.static <T extends boofcv.struct.image.ImageBase<T>>
TcreateSubImageOf(T input)Returns an image which is a sub-image but contains the same values of the input image.static <T extends boofcv.struct.image.ImageInterleaved<T>>
TcreateSubImageOf_I(T input)static <T extends boofcv.struct.image.Planar>
TcreateSubImageOf_PL(T input)static <T extends boofcv.struct.image.ImageGray<T>>
TcreateSubImageOf_S(T input)static boofcv.concurrency.WorkArrayscreateWorkArray(java.lang.Class<?> type, int length)static java.lang.reflect.MethodfindMethod(java.lang.Class<?> type, java.lang.String name, java.lang.Class<?>... params)Searches for a function which is a perfect match.static intfindMethodThenCall(java.lang.Object owner, java.lang.String ownerMethod, java.lang.Class target, java.lang.String targetMethod)Searches for all functions with the specified name in the target class.static java.lang.Objectprimitive(java.lang.Object v, java.lang.Class type)static voidprintDiff(boofcv.struct.image.ImageGray imgA, boofcv.struct.image.ImageGray imgB)static voidprintDiffBinary(boofcv.struct.image.GrayU8 imgA, boofcv.struct.image.GrayU8 imgB)static java.lang.ObjectrandomArray(java.lang.Class type, int length, java.util.Random rand)
-
-
-
Field Detail
-
BASE_SEED
public static final long BASE_SEED
- See Also:
- Constant Field Values
-
-
Method Detail
-
createRandom
public static java.util.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
-
convertToGenericType
public static <T> T convertToGenericType(java.lang.Class<?> type)
-
convertToGenericType
public static boofcv.struct.image.ImageDataType convertToGenericType(boofcv.struct.image.ImageDataType type)
-
createSubImageOf
public static <T extends boofcv.struct.image.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 boofcv.struct.image.ImageGray<T>> T createSubImageOf_S(T input)
-
createSubImageOf_I
public static <T extends boofcv.struct.image.ImageInterleaved<T>> T createSubImageOf_I(T input)
-
createSubImageOf_PL
public static <T extends boofcv.struct.image.Planar> T createSubImageOf_PL(T input)
-
checkImageDimensionValidation
public static void checkImageDimensionValidation(java.lang.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(java.lang.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(java.lang.Object testClass, java.lang.String function, boolean checkEquals, java.lang.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 typeGrayU8.- 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 outputinputParam- The original input parameters
-
findMethod
public static java.lang.reflect.Method findMethod(java.lang.Class<?> type, java.lang.String name, java.lang.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(java.lang.Class<?> classType, java.lang.String name, java.lang.Object... inputs)Looks up the static method then passes in the specified inputs.
-
findMethodThenCall
public static int findMethodThenCall(java.lang.Object owner, java.lang.String ownerMethod, java.lang.Class target, java.lang.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.- Parameters:
owner-ownerMethod-target-targetMethod-- 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(boofcv.struct.image.ImageBase imgA, boofcv.struct.image.ImageBase imgB, double tol)
-
assertEqualsInner
public static void assertEqualsInner(boofcv.struct.image.ImageBase imgA, boofcv.struct.image.ImageBase imgB, double tol, int borderX, int borderY, boolean relative)
-
assertEqualsInner
public static void assertEqualsInner(boofcv.struct.image.ImageBase imgA, boofcv.struct.image.ImageBase imgB, double tol, int borderX0, int borderY0, int borderX1, int borderY1, boolean relative)
-
assertEqualsRelative
public static void assertEqualsRelative(boofcv.struct.image.ImageBase imgA, boofcv.struct.image.ImageBase imgB, double tolFrac)
-
assertEqualsBorder
public static void assertEqualsBorder(boofcv.struct.image.ImageBase imgA, boofcv.struct.image.ImageBase imgB, double tol, int borderX, int borderY)
-
assertEqualsBorder
public static void assertEqualsBorder(boofcv.struct.image.ImageGray imgA, boofcv.struct.image.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(boofcv.struct.image.ImageInterleaved imgA, boofcv.struct.image.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(boofcv.struct.image.ImageGray outputImage, int border)
-
checkBorderZero
public static void checkBorderZero(boofcv.struct.image.ImageGray outputImage, int borderX0, int borderY0, int borderX1, int borderY1)
-
printDiff
public static void printDiff(boofcv.struct.image.ImageGray imgA, boofcv.struct.image.ImageGray imgB)
-
printDiffBinary
public static void printDiffBinary(boofcv.struct.image.GrayU8 imgA, boofcv.struct.image.GrayU8 imgB)
-
randomArray
public static java.lang.Object randomArray(java.lang.Class type, int length, java.util.Random rand)
-
primitive
public static java.lang.Object primitive(java.lang.Object v, java.lang.Class type)
-
createInstance
public static java.lang.Object createInstance(java.lang.Class<?> type)
-
createWorkArray
public static boofcv.concurrency.WorkArrays createWorkArray(java.lang.Class<?> type, int length)
-
-