Auxilliary Tool:
A set of functions that are commonly used by many NMPT classes and executables.
More...
Functions | |
void | printMat (const cv::Mat &mat) |
Display a matrix to stdout in a multi line format easy to read. | |
void | printMat (const CvMat &mat) |
Display a matrix to stdout in a multi line format easy to read. | |
double | randomNormal () |
Get a single normally distributed random number. | |
double | randomFloat () |
Get a single random number distributed uniformly from 0-1. | |
std::string | commaSeparatedFlattenedMat (const cv::Mat &mat) |
Format a matrix in a single line, comma separated format suitable for output to a CSV file. | |
int | getVideoCaptureFromCommandLineArgs (cv::VideoCapture &capture, const int argc, const char **argv) |
Allows the source for an NMPT program to be specified from the command line. | |
double | rectAreaOverlapRatio (cv::Rect r1, cv::Rect r2) |
Computes the ratio of the area of the intersection of two rectangles to the area of the union. | |
double | rectAreaIntersect (cv::Rect r1, cv::Rect r2) |
Computes the area of the intersection of two rectangles. | |
double | notfinite (double a) |
Returns true if a is NaN or infinty. | |
void | distNorm (cv::Mat &normDist, const cv::Mat &unnormDist) |
Divides unnormDist by its L1-norm, effectively turning it into a probability distribution's histogram. The values of unnormDist should be all positive. If any values are NaN or inf, the probability mass is split uniformly between those values and all other values become 0. | |
void | sample (cv::Mat &samples, const cv::Mat &histogram, cv::Size sampleSize=cv::Size(1, 1)) |
Generate a matrix of samples from a probability histogram. | |
int | sample (const cv::Mat &histogram) |
Generate a single sample from a probability histogram. | |
template<class mattype > | |
void | map (cv::Mat &mat, mattype(*function)(mattype)) |
Apply a function (in place) to every element of a matrix. The function must take an argument of the matrix's data type, and return a value of the matrix's data type. | |
template<class mattype > | |
int | contains (const cv::Mat &mat, mattype val) |
Check to see if a matrix contains a certain value. | |
double | nchoosek (int n, int k) |
Quickly computer the n choose k function. The result is accurate through at least the range of 32-bit integers. | |
int | any (CvMat *mat) |
Checks to see if any member of mat is non-zero. | |
template<class mattype > | |
int | any (const cv::Mat &mat) |
Checks to see if any member of mat is non-zero. | |
void | fix (CvMat *mat) |
Round the elements of mat towards zero. | |
void | writeMatBinary (cv::FileStorage &storage, const std::string &name, const cv::Mat &mat) |
Write the value of a matrix to a FileStorage in a Base64 format that is much more compact than OpenCV's default format. The data is keyed by the supplied name. | |
void | readMatBinary (const cv::FileNode &storage, cv::Mat &mat) |
Read the value of a matrix to a FileStorage in a Base64 format that is much more compact than OpenCV's default format. The data is keyed by the supplied name. If you attempt to read a matrix that was not saved with "writeMatBinary," this will probably crash your program. | |
void | binaryToAscii (std::string &dest, const uchar *data, size_t bytes) |
Read the value of a matrix to a FileStorage in a Base64 format that is much more compact than OpenCV's default format. The data is keyed by the supplied name. The data is uncompressed with zlib after writing. If you attempt to read a matrix that was not saved with "writeMatBinaryCompressed," this will probably crash your program. | |
void | asciiToBinary (const std::string &data, uchar *dest, size_t bytes) |
Converts a Base64 string to binary data. | |
void | binaryToHex (std::string &dest, const uchar *data, size_t bytes) |
Converts binary data to a non-standard hex format that can be written to a text file, e.g. the YAML format written by OpenCV. This format requires 1.5 the storage space of Base64. | |
void | hexToBinary (const std::string &data, uchar *dest, size_t bytes) |
Converts a non-standard hex format to binary data. This format requires 1.5 the storage space of Base64. | |
void | splitString (std::vector< std::string > &dest, const std::string &data, size_t maxlen=512) |
Splits a string into a collection of string vectors, each with maximum length maxlen. This is useful because OpenCV imposes a maximum string length when writing to a file, somewhere between 2048 and 4096. | |
void | joinString (const std::vector< std::string > &data, std::string &dest) |
Rejoins a vector of strings into a single string. | |
void | rectangleRotated (cv::Mat &image, cv::Point center, cv::Size size, double angle, const cv::Scalar &color, int thickness=1, int lineType=8, int shift=0) |
Uses zlib to compress data. The output dest is allocated in this function and dest_size is set to the number of bytes of the compressed data. Returns a zlib error code if compression fails. | |
void | unIntegrate (const cv::Mat &src, cv::Mat &dest, int type=CV_8U) |
Calculate derivative image. | |
void | unSqIntegrate (const cv::Mat &src, cv::Mat &dest, int type=CV_8U) |
Calculate sqrt of derivative image. | |
cv::Mat | RBF (const cv::Mat &input, const cv::Mat &labels, const cv::Mat &weights, const cv::Mat &xqueries, double tau=.05, double eps=.001) |
Compute RBF values at supplied query points, given input data and labels. |
Auxilliary Tool:
A set of functions that are commonly used by many NMPT classes and executables.
void NMPTUtils::binaryToAscii | ( | std::string & | dest, |
const uchar * | data, | ||
size_t | bytes | ||
) |
Read the value of a matrix to a FileStorage in a Base64 format that is much more compact than OpenCV's default format. The data is keyed by the supplied name. The data is uncompressed with zlib after writing. If you attempt to read a matrix that was not saved with "writeMatBinaryCompressed," this will probably crash your program.
Converts binary data to a Base64 string that can be written to a text file, e.g. the YAML format written by OpenCV.
int NMPTUtils::getVideoCaptureFromCommandLineArgs | ( | cv::VideoCapture & | capture, |
const int | argc, | ||
const char ** | argv | ||
) |
Allows the source for an NMPT program to be specified from the command line.
Returns 0 if there was an error, 1 if a video file was the source, or 2 if a camera was the source,
cv::Mat NMPTUtils::RBF | ( | const cv::Mat & | input, |
const cv::Mat & | labels, | ||
const cv::Mat & | weights, | ||
const cv::Mat & | xqueries, | ||
double | tau = .05 , |
||
double | eps = .001 |
||
) |
Compute RBF values at supplied query points, given input data and labels.
input | NxM, N data points, M Dims |
labels | NxO, N data points, O outputs |
weights | Nx1, 1 weight per data point |
xqueries | QxM, Q query points, M Dims |
tau,: | variance of gaussian weighting window |
eps,: | minimal attention paid to all points |
void NMPTUtils::rectangleRotated | ( | cv::Mat & | image, |
cv::Point | center, | ||
cv::Size | size, | ||
double | angle, | ||
const cv::Scalar & | color, | ||
int | thickness = 1 , |
||
int | lineType = 8 , |
||
int | shift = 0 |
||
) |
Uses zlib to compress data. The output dest is allocated in this function and dest_size is set to the number of bytes of the compressed data. Returns a zlib error code if compression fails.
Uncompress data that was previously compressed. The output dest is allocated in this function, to the amount specified by dest_size. This should be the size of the original uncompressed data, which presumably you know, because you compressed it. Returns a zlib error code if decompression fails. Draw a rotated rectangle on an image. The point is to be like opencv's cv::rectangle function, but to allow rotation.