Package boofcv
Class BoofTesting
java.lang.Object
boofcv.BoofTesting
Functions to aid in unit testing code for correctly handling sub-images
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
assertEquals
(byte[] a, byte[] b) static void
assertEquals
(double[] a, double[] b, double tol) static void
assertEquals
(double[] a, float[] b, double tol) static void
assertEquals
(double[] a, int[] b) static void
assertEquals
(float[] a, float[] b, float tol) static void
assertEquals
(int[] a, int[] b) static void
assertEquals
(long[] a, long[] b) static void
assertEquals
(short[] a, short[] b) static void
assertEquals
(ImageBase imgA, ImageBase imgB, double tol) static void
assertEquals
(Se3_F64 expected, Se3_F64 found, double tolAngle, double tolT) static void
assertEqualsBorder
(ImageBase imgA, ImageBase imgB, double tol, int borderX, int borderY) 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 tolerancestatic 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 tolerancestatic void
assertEqualsInner
(ImageBase imgA, ImageBase imgB, double tol, int borderX, int borderY, boolean relative) static void
assertEqualsInner
(ImageBase imgA, ImageBase imgB, double tol, int borderX0, int borderY0, int borderX1, int borderY1, boolean relative) static void
assertEqualsRelative
(ImageBase imgA, ImageBase imgB, double tolFrac) 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.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.static void
callStaticMethod
(Class<?> classType, String name, Object... inputs) Looks up the static method then passes in the specified inputs.static void
checkBorderZero
(ImageGray outputImage, int border) static void
checkBorderZero
(ImageGray outputImage, int borderX0, int borderY0, int borderX1, int borderY1) 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.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.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.static <T> T
convertToGenericType
(@Nullable Class<?> type) static ImageDataType
static Object
createInstance
(Class<?> type) static Random
createRandom
(long offset) Creates Random but using a fixed seed with an offset.static <T extends 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 ImageInterleaved<T>>
TcreateSubImageOf_I
(T input) static <T extends Planar>
TcreateSubImageOf_PL
(T input) static <T extends ImageGray<T>>
TcreateSubImageOf_S
(T input) static Method
findMethod
(Class<?> type, String name, Class<?>... params) Searches for a function which is a perfect match.static int
findMethodThenCall
(Object owner, String ownerMethod, Class target, String targetMethod) Searches for all functions with the specified name in the target class.static Object
static void
static void
printDiffBinary
(GrayU8 imgA, GrayU8 imgB) static ImageDataType
pritiveToImageDataType
(Class type) static Object
randomArray
(Class type, int length, Random rand) static double
tolerance
(ImageDataType type) Recommended tolerance by image data type.
-
Field Details
-
BASE_SEED
public static final long BASE_SEED- See Also:
-
-
Constructor Details
-
BoofTesting
public BoofTesting()
-
-
Method Details
-
createRandom
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
Recommended tolerance by image data type. Useful when processing images but the type isn't known at compile time. -
convertToGenericType
-
convertToGenericType
-
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 transformfound
- the found transformtolAngle
- radianstolT
- 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 transformfound
- the found transformtolAngle
- radianstolT
- fractional error tolernace
-
assertEquals
-
createSubImageOf
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
-
createSubImageOf_I
-
createSubImageOf_PL
-
checkImageDimensionValidation
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
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 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
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
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
-
assertEqualsInner
-
assertEqualsInner
-
assertEqualsRelative
-
assertEqualsBorder
-
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
-
checkBorderZero
public static void checkBorderZero(ImageGray outputImage, int borderX0, int borderY0, int borderX1, int borderY1) -
printDiff
-
printDiffBinary
-
randomArray
-
pritiveToImageDataType
-
primitive
-
createInstance
-