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
Parameters: |
|
---|
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() .
Checks a condition at runtime.
#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);
Exception(const Exception& exc);
Exception& operator = (const Exception& exc);
// the error code
int code;
// the error text message
string err;
// function name where the error happened
string func;
// the source file name where the error happened
string file;
// 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
Parameters: |
|
---|
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
Parameters: |
|
---|
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
Parameters: |
|
---|
The function acts like sprintf , but forms and returns STL string. It can be used for form the error message in Exception() constructor.
Returns the number of threads used by OpenCV
The function returns the number of threads that is used by OpenCV.
See also: setNumThreads() , getThreadNum() .
Returns index of the currently executed thread
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() .
Returns the number of ticks
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.
Returns the number of ticks per second
The function returns the number of ticks per second. That is, the following code computes the execution time in seconds.
double t = (double)getTickCount();
// do something ...
t = ((double)getTickCount() - t)/getTickFrequency();
Sets the number of threads used by OpenCV
Parameters: |
|
---|
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()