Package boofcv
Class BoofTesting
java.lang.Object
boofcv.BoofTesting
Functions to aid in unit testing code for correctly handling sub-images
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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(ImageBase imgA, ImageBase imgB, double tol) static voidassertEquals(Se3_F64 expected, Se3_F64 found, double tolAngle, double tolT) static voidassertEqualsBorder(ImageBase imgA, ImageBase imgB, double tol, int borderX, int borderY) static voidassertEqualsBorder(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 voidassertEqualsBorder(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 voidassertEqualsInner(ImageBase imgA, ImageBase imgB, double tol, int borderX, int borderY, boolean relative) static voidassertEqualsInner(ImageBase imgA, ImageBase imgB, double tol, int borderX0, int borderY0, int borderX1, int borderY1, boolean relative) static voidassertEqualsRelative(ImageBase imgA, ImageBase imgB, double tolFrac) static voidassertEqualsToScale(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 voidassertEqualsToScaleS(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 voidcallStaticMethod(Class<?> classType, String name, Object... inputs) Looks up the static method then passes in the specified inputs.static voidcheckBorderZero(ImageGray outputImage, int border) static voidcheckBorderZero(ImageGray outputImage, int borderX0, int borderY0, int borderX1, int borderY1) static voidcheckImageDimensionReshape(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(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(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> TconvertToGenericType(@Nullable Class<?> type) static ImageDataTypestatic ObjectcreateInstance(Class<?> type) static RandomcreateRandom(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 MethodfindMethod(Class<?> type, String name, Class<?>... params) Searches for a function which is a perfect match.static intfindMethodThenCall(Object owner, String ownerMethod, Class target, String targetMethod) Searches for all functions with the specified name in the target class.static Objectstatic voidstatic voidprintDiffBinary(GrayU8 imgA, GrayU8 imgB) static ImageDataTypepritiveToImageDataType(Class type) static ObjectrandomArray(Class type, int length, Random rand) static doubletolerance(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
-