Package boofcv.misc
Class BoofMiscOps
java.lang.Object
boofcv.misc.BoofMiscOps
Miscellaneous functions which have no better place to go.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic intNumber of characters in the class name prefix in verbose printingstatic booleanPrints a table explaining what the prefixes are -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable PrintStreamaddPrefix(VerbosePrint owner, int numIndents, @Nullable PrintStream out) static @Nullable PrintStreamaddPrefix(VerbosePrint owner, @Nullable PrintStream out) static <T> List<T>asList(T... objects) static intbitsToWords(int bits, int wordBits) static intbitToByteCount(int numBits) Returns number of bytes that are needed to store the specified number of bitsstatic booleanblockUntilTrue(long timeoutMS, BoofLambdas.CheckTrue func) Blocks until the provided function returns true.static doublebound(double value, double min, double max) static floatbound(float value, float min, float max) static voidBounds the provided rectangle to be inside the image.static StringbyteArrayToHex(byte[] array) static byte[]castStringToByteArray(String message) Converts a string into a byte array.static boolean[]checkDeclare(@Nullable DogArray_B queue, int length, boolean zero) static float[]checkDeclare(@Nullable DogArray_F32 queue, int length, boolean zero) static double[]checkDeclare(@Nullable DogArray_F64 queue, int length, boolean zero) static int[]checkDeclare(@Nullable DogArray_I32 queue, int length, boolean zero) static byte[]checkDeclare(@Nullable DogArray_I8 queue, int length, boolean zero) static <T> GrowArray<T>checkDeclare(@Nullable GrowArray<T> growable, ConcurrencyOps.NewInstance<T> factory) static voidcheckEq(int valA, int valB) static voidstatic voidcheckFraction(double fraction, String message) Checks to see if the passed in value is a fraction from 0 to 1.0, inclusivestatic voidstatic voidstatic voidcheckTrue(boolean result) static voidstatic <In,Out> List<Out> collectList(List<In> list, BoofLambdas.Extract<In, Out> func) Extracts elements from a list and returns a liststatic intcolumnMaxAbsRow(DMatrixRMaj A, int column) Finds the row at the specified column with the maximum absolute valuestatic <T> booleancontainsDuplicates(List<T> list) Checks to see if the list contains duplicate itemsstatic float[]convertArray(double[] input, @org.jetbrains.annotations.Nullable float[] output) static int[]convertArray(double[] input, @org.jetbrains.annotations.Nullable int[] output) static long[]convertArray(double[] input, @org.jetbrains.annotations.Nullable long[] output) static double[]convertArray(float[] input, @org.jetbrains.annotations.Nullable double[] output) static int[]convertArray(float[] input, @org.jetbrains.annotations.Nullable int[] output) static float[]convertArray(int[] input, @org.jetbrains.annotations.Nullable float[] output) static voidconvertMatrix(DMatrix2x2 src, DMatrixRMaj dst) Convert matrix and work in auto generate F32 codestatic voidconvertMatrix(FMatrix2x2 src, DMatrixRMaj dst) Convert matrix and work in auto generate F32 codestatic float[]convertTo_F32(double[] a, float[] ret) static double[]convertTo_F64(int[] a) static int[]convertTo_I32(double[] a, int[] ret) static <Point extends GeoTuple<Point>>
voidcopyAll(FastAccess<Point> src, DogArray<Point> dst) Copies all of src into dst by appended it onto itstatic <C extends Configuration>
CcopyConfig(C src) Creates a copy of the passed inConfigurationstatic double[]copySmart(double[] src, @org.jetbrains.annotations.Nullable double[] dst) Copies src into dst.static intcountNotZero(int[] a, int size) static <T> List<T>createListFilled(int total, BoofLambdas.Factory<T> factory) static doublediffRatio(double a, double b) static inteditDistance(String s1, String s2) static <T> voidforIdx(List<T> list, BoofLambdas.ProcessIndex<T> func) static intgenerateBitMask(int numBits) Generates mask where the first N bits are filled in with 1static intReturns the major version of java or -1 if it failed.static <V> VgetOrThrow(Map map, Object key) static StringhandlePathTilde(String path) Checks to see if the passed in string starts with a ~ and if so it will replace it with the users home directory.static <T> Set<T>hashSet(T... values) static <T> intindexOf(List<T> list, BoofLambdas.Filter<T> op) Searches the list for the first index where the operation returns true.static booleanisInside(int width, int height, double x, double y) static booleanisInside(int width, int height, float x, float y) static booleanstatic booleanReturns true if the point is contained inside the image and 'radius' away from the image border.static booleanstatic booleanReturns true if the point is contained inside the image and 'radius' away from the image border.static booleanReturns true if the point is contained inside the image and 'radius' away from the image border.static booleanstatic booleanstatic booleanisInside(ImageBase b, ImageRectangle r) static double[]ConvertsList<double>into double[].static Stringmd5sum(byte[] data) Computes MD5SUM of byte data as a stringstatic StringmilliToHuman(long milliseconds) static doublemin(double a, double b, double c) static floatmin(float a, float b, float c) static intmin(int a, int b, int c) static StringnameToShort(String name, int length) Assumes names are camel case and that the capital letters are important.static intstatic intnumDigits(int number) Returns the number of digits in a number.static voidoffsetPixels(List<Point2D_F64> list, double dx, double dy) static booleanparseDimension(String text, ImageDimension dimension) Parses the string into a dimension.static voidpause(long milli) Invokes wait until the elapsed time has passed.static doublepow2(double v) static floatpow2(float v) static voidstatic voidstatic voidstatic voidstatic voidstatic voidprintMethodInfo(Method target, PrintStream out) static voidprofile(BoofLambdas.ProcessCall process, String description) static intquadraticSolver(double a, double b, double c, double[] solutions) Carefully constructed quadratic equation solver that attempts to maximize numerical stability and gracefully handle zeros in coefficients.static <T> TremoveTail(List<T> list) Returns and removes the last element in the list.static doublesimilarity(String s1, String s2) Calculates the similarity (a number within 0 and 1) between two strings.static voidsleep(long milli) static voidsortFileNames(List<String> images) static voidsortFilesByName(List<File> images) static <T> TReturns the last element in the list.static doublethresholdByImageSize(ConfigLength config, int width, int height) Standard formula for computing a relative threshold based on the image size.static intthresholdByImageSizeI(ConfigLength config, int width, int height) Standard formula for computing a relative threshold based on the image size.static longtimeNano(BoofLambdas.ProcessCall process) Computes the elapsed time in calling the provided function in nano secondsstatic StringtimeStr()static StringtimeStr(long systemTimeMS) toFileList(String[] files) toFileList(List<String> files) static Stringstatic <T> StringtoString(T o, BoofLambdas.ToString<T> op) Safe way to convert an object to string which checks to see if object is nullstatic String[]toStringArray(List<File> files) static <T> StringtoStringLine(List<T> list) static doubleReturns a random number from min to max, inclusive.static floatReturns a random number from min to max, inclusive.static voidverboseChildren(@Nullable PrintStream out, @Nullable Set<String> configuration, @Nullable VerbosePrint... children) Function which handles boilerplate for support recursive verbose print
-
Field Details
-
VERBOSE_PREFIX_LENGTH
public static int VERBOSE_PREFIX_LENGTHNumber of characters in the class name prefix in verbose printing -
VERBOSE_PRINT_TABLE
public static boolean VERBOSE_PRINT_TABLEPrints a table explaining what the prefixes are
-
-
Constructor Details
-
BoofMiscOps
public BoofMiscOps()
-
-
Method Details
-
timeNano
Computes the elapsed time in calling the provided function in nano seconds -
profile
-
timeStr
-
timeStr
-
handlePathTilde
Checks to see if the passed in string starts with a ~ and if so it will replace it with the users home directory. -
bound
public static float bound(float value, float min, float max) -
bound
public static double bound(double value, double min, double max) -
offsetPixels
-
toStringArray
-
copyAll
public static <Point extends GeoTuple<Point>> void copyAll(FastAccess<Point> src, DogArray<Point> dst) Copies all of src into dst by appended it onto it -
toFileList
-
asList
-
toFileList
-
bitsToWords
public static int bitsToWords(int bits, int wordBits) -
numBands
-
milliToHuman
-
diffRatio
public static double diffRatio(double a, double b) -
numDigits
public static int numDigits(int number) Returns the number of digits in a number. E.g. 345 = 3, -345 = 4, 0 = 1 -
pow2
public static double pow2(double v) -
pow2
public static float pow2(float v) -
sortFileNames
-
sortFilesByName
-
printMethodInfo
-
parseDimension
Parses the string into a dimension. The two numbers are seperated with a colon. -
quadraticSolver
public static int quadraticSolver(double a, double b, double c, double[] solutions) Carefully constructed quadratic equation solver that attempts to maximize numerical stability and gracefully handle zeros in coefficients.a*x*x + b*c + c = 0. Solve for x.
- Parameters:
solutions- (Output) storage for up to two solutions.- Returns:
- Number of valid solutions found
-
toString
-
countNotZero
public static int countNotZero(int[] a, int size) -
convertTo_F64
public static double[] convertTo_F64(int[] a) -
convertTo_F32
public static float[] convertTo_F32(double[] a, float[] ret) -
convertTo_I32
public static int[] convertTo_I32(double[] a, int[] ret) -
boundRectangleInside
Bounds the provided rectangle to be inside the image.- Parameters:
b- An image.r- Rectangle
-
min
public static double min(double a, double b, double c) -
min
public static float min(float a, float b, float c) -
min
public static int min(int a, int b, int c) -
isInside
-
isInside
Returns true if the point is contained inside the image and 'radius' away from the image border.- Parameters:
b- Imagex- x-coordinate of pointy- y-coordinate of pointradius- How many pixels away from the border it needs to be to be considered inside- Returns:
- true if the point is inside and false if it is outside
-
isInside
Returns true if the point is contained inside the image and 'radius' away from the image border.- Parameters:
b- Imagex- x-coordinate of pointy- y-coordinate of pointradius- How many pixels away from the border it needs to be to be considered inside- Returns:
- true if the point is inside and false if it is outside
-
isInside
Returns true if the point is contained inside the image and 'radius' away from the image border.- Parameters:
b- Imagex- x-coordinate of pointy- y-coordinate of pointradius- How many pixels away from the border it needs to be to be considered inside- Returns:
- true if the point is inside and false if it is outside
-
isInside
-
isInside
-
isInside
-
isInside
-
isInside
public static boolean isInside(int width, int height, float x, float y) -
isInside
public static boolean isInside(int width, int height, double x, double y) -
pause
public static void pause(long milli) Invokes wait until the elapsed time has passed. In the thread is interrupted, the interrupt is ignored.- Parameters:
milli- Length of desired pause in milliseconds.
-
print
-
print
-
print
-
print
-
print
-
convertArray
public static int[] convertArray(double[] input, @Nullable @org.jetbrains.annotations.Nullable int[] output) -
convertArray
public static long[] convertArray(double[] input, @Nullable @org.jetbrains.annotations.Nullable long[] output) -
convertArray
public static float[] convertArray(double[] input, @Nullable @org.jetbrains.annotations.Nullable float[] output) -
convertArray
public static double[] convertArray(float[] input, @Nullable @org.jetbrains.annotations.Nullable double[] output) -
convertArray
public static int[] convertArray(float[] input, @Nullable @org.jetbrains.annotations.Nullable int[] output) -
convertArray
public static float[] convertArray(int[] input, @Nullable @org.jetbrains.annotations.Nullable float[] output) -
sleep
public static void sleep(long milli) -
checkTrue
public static void checkTrue(boolean result) -
checkTrue
-
checkEq
public static void checkEq(int valA, int valB) -
checkEq
-
checkSame
-
checkSame
-
checkFraction
Checks to see if the passed in value is a fraction from 0 to 1.0, inclusive -
forIdx
-
indexOf
Searches the list for the first index where the operation returns true. When a match is found it returns the index. Otherwise it returns -1 if no match is found. -
collectList
Extracts elements from a list and returns a list -
uniform
Returns a random number from min to max, inclusive. -
uniform
Returns a random number from min to max, inclusive. -
tail
Returns the last element in the list. Does not check if the list is empty -
removeTail
Returns and removes the last element in the list. Does not check if the list is empty -
toString
Safe way to convert an object to string which checks to see if object is null -
columnMaxAbsRow
Finds the row at the specified column with the maximum absolute value- Parameters:
A- (input) matrixcolumn- column to inspect- Returns:
- The row index
-
createListFilled
-
getOrThrow
- Throws:
IOException
-
listToArrayDouble
ConvertsList<double>into double[]. If already an array it simply returns the original array -
containsDuplicates
Checks to see if the list contains duplicate items -
checkDeclare
public static boolean[] checkDeclare(@Nullable @Nullable DogArray_B queue, int length, boolean zero) -
checkDeclare
-
checkDeclare
-
checkDeclare
public static float[] checkDeclare(@Nullable @Nullable DogArray_F32 queue, int length, boolean zero) -
checkDeclare
public static double[] checkDeclare(@Nullable @Nullable DogArray_F64 queue, int length, boolean zero) -
checkDeclare
public static <T> GrowArray<T> checkDeclare(@Nullable @Nullable GrowArray<T> growable, ConcurrencyOps.NewInstance<T> factory) -
similarity
Calculates the similarity (a number within 0 and 1) between two strings. This is case insensitive. Taken from stack overflow, which was taken from some place else. -
editDistance
-
copyConfig
Creates a copy of the passed inConfiguration -
verboseChildren
public static void verboseChildren(@Nullable @Nullable PrintStream out, @Nullable @Nullable Set<String> configuration, @Nullable @Nullable VerbosePrint... children) Function which handles boilerplate for support recursive verbose print -
toStringLine
-
addPrefix
@Nullable public static @Nullable PrintStream addPrefix(VerbosePrint owner, @Nullable @Nullable PrintStream out) -
addPrefix
@Nullable public static @Nullable PrintStream addPrefix(VerbosePrint owner, int numIndents, @Nullable @Nullable PrintStream out) -
nameToShort
Assumes names are camel case and that the capital letters are important. Same for numbers -
hashSet
-
convertMatrix
Convert matrix and work in auto generate F32 code -
convertMatrix
Convert matrix and work in auto generate F32 code -
copySmart
public static double[] copySmart(double[] src, @Nullable @org.jetbrains.annotations.Nullable double[] dst) Copies src into dst. If dst is not the correct size then a new instance is created and that returned. -
generateBitMask
public static int generateBitMask(int numBits) Generates mask where the first N bits are filled in with 1 -
getJavaVersion
public static int getJavaVersion()Returns the major version of java or -1 if it failed. -
castStringToByteArray
Converts a string into a byte array. No encoding is used and it is literally casting each character into a byte. This is useful when you have a marker that really just encodes binary data.- Parameters:
message- String with raw bytes encoded inside of it.- Returns:
- byte array conversion of the string.
-
md5sum
Computes MD5SUM of byte data as a string -
byteArrayToHex
-
bitToByteCount
public static int bitToByteCount(int numBits) Returns number of bytes that are needed to store the specified number of bits -
thresholdByImageSize
Standard formula for computing a relative threshold based on the image size. Computed as the average of the width and height. This it will scale linearly with the perimeter and not the area. -
thresholdByImageSizeI
Standard formula for computing a relative threshold based on the image size. Computed as the average of the width and height. This it will scale linearly with the perimeter and not the area. -
blockUntilTrue
Blocks until the provided function returns true.- Parameters:
timeoutMS- Timeout in milliseconds. If ≤ 0 then it will never time outfunc- Function- Returns:
- true if the function return true or false if it timed out.
-