Aligns pointer to the specified number of bytes
Parameters: |
|
---|
The function returns the aligned pointer of the same type as the input pointer:
Aligns a buffer size to the specified number of bytes
Parameters: |
|
---|
The function returns the minimum number that is greater or equal to sz and is divisble by n :
Allocates an array of elements
Parameter: | n – The number of elements to allocate |
---|
The generic function allocate allocates buffer for the specified number of elements. For each element the default constructor is called.
Allocates an array of elements
Parameters: |
|
---|
The generic function deallocate deallocates the buffer allocated with allocate() . The number of elements must match the number passed to allocate() .
#define CV_Assert( expr ) ...
#define CV_DbgAssert(expr) ...
param expr: The checked expression
The macros CV_Assert and CV_DbgAssert evaluate the specified expression and if it is 0, the macros raise an error (see error() ). The macro CV_Assert checks the condition in both Debug and Release configurations, while CV_DbgAssert is only retained in the Debug configuration.
Signals an error and raises the exception
Parameters: |
|
---|
The function and the helper macros CV_Error and CV_Error_ call the error handler. Currently, the error handler prints the error code ( exc.code ), the context ( exc.file , exc.line and the error message exc.err to the standard error stream stderr . In Debug configuration it then provokes memory access violation, so that the execution stack and all the parameters can be analyzed in debugger. In Release configuration the exception exc is thrown.
The macro CV_Error_ can be used to construct the error message on-fly to include some dynamic information, for example:
// note the extra parentheses around the formatted text message
CV_Error_(CV_StsOutOfRange,
("the matrix element (
i, j, mtx.at<float>(i,j)))
The exception class passed to error
class Exception
{
public:
// various constructors and the copy operation
Exception() { code = 0; line = 0; }
Exception(int _code, const string& _err,
const string& _func, const string& _file, int _line);newline
Exception(const Exception& exc);newline
Exception& operator = (const Exception& exc);newline
// the error code
int code;newline
// the error text message
string err;newline
// function name where the error happened
string func;newline
// the source file name where the error happened
string file;newline
// the source file line where the error happened
int line;
};
The class Exception encapsulates all or almost all the necessary information about the error happened in the program. The exception is usually constructed and thrown implicitly, via CV_Error and CV_Error_ macros, see error() .
Allocates aligned memory buffer
Parameter: | size – The allocated buffer size |
---|
The function allocates buffer of the specified size and returns it. When the buffer size is 16 bytes or more, the returned buffer is aligned on 16 bytes.
Deallocates memory buffer
Parameter: | ptr – Pointer to the allocated buffer |
---|
The function deallocates the buffer, allocated with fastMalloc() . If NULL pointer is passed, the function does nothing.
Returns a text string formatted using printf-like expression
Parameter: | fmt – The printf-compatible formatting specifiers |
---|
The function acts like sprintf , but forms and returns STL string. It can be used for form the error message in Exception() constructor.
The function returns the number of threads that is used by OpenCV.
See also: setNumThreads() , getThreadNum() .
The function returns 0-based index of the currently executed thread. The function is only valid inside a parallel OpenMP region. When OpenCV is built without OpenMP support, the function always returns 0.
See also: setNumThreads() , getNumThreads() .
The function returns the number of ticks since the certain event (e.g. when the machine was turned on). It can be used to initialize RNG() or to measure a function execution time by reading the tick count before and after the function call. See also the tick frequency.
The function returns the number of ticks per second. That is, the following code computes the executing time in seconds.
double t = (double)getTickCount();
// do something ...
t = ((double)getTickCount() - t)/getTickFrequency();
Sets the number of threads used by OpenCV
Parameter: | nthreads – The number of threads used by OpenCV |
---|
The function sets the number of threads used by OpenCV in parallel OpenMP regions. If nthreads=0 , the function will use the default number of threads, which is usually equal to the number of the processing cores.
See also: getNumThreads() , getThreadNum()