Joe Verbout / Mbed 2 deprecated main

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

C API

Functions

 CVAPI (void) cvReleaseHaarClassifierCascade(CvHaarClassifierCascade **cascade)
 Deallocates an image header.

Function Documentation

CVAPI ( void   )

Deallocates an image header.

Draws contour outlines or filled interiors on the image.

Calculates bounding box of text stroke (useful for alignment)

Renders text stroke with specified font and color at specified location.

Initializes font structure (OpenCV 1.x API).

Draws one or more polygonal curves.

Fills an area bounded by one or more arbitrary polygons.

Fills convex or monotonous polygon.

Draws ellipse outline, filled ellipse, elliptic arc or filled elliptic sector.

Draws a circle with specified center and radius.

Draws a rectangle specified by a CvRect structure.

Draws a rectangle given two opposite corners of the rectangle (pt1 & pt2)

Draws 4-connected, 8-connected or antialiased line segment connecting two points.

Fits a line into set of 2d or 3d points in a robust way (M-estimator technique)

Finds a sparse set of points within the selected region that seem to be easy to track.

Adjust corner position using some sort of gradient search.

Harris corner detector:

Calculates minimal eigenvalue for 2x2 gradient covariation matrix at every image pixel.

Calculates eigen values and vectors of 2x2 gradient covariation matrix at every image pixel.

Calculates constraint image for corner detection.

Runs canny edge detector.

Fills the connected component until the color difference gets large enough.

Applies adaptive threshold to grayscale image.

Applies distance transform to binary image.

equalizes histogram of 8-bit single-channel image

Divides one histogram by another.

Locates a template within an image by using a histogram comparison.

Calculates back project.

Calculates array histogram.

Calculates bayesian probabilistic histograms (each or src and dst is an array of _number_ histograms.

Copies a histogram.

Thresholds the histogram.

Normalizes the histogram.

Finds the minimum and maximum histogram bins.

Clears the histogram.

Releases the histogram.

Sets the bounds of the histogram bins.

Finds coordinates of the box vertices.

Initializes Freeman chain reader.

Substitutes the last retrieved contour with the new one.

Measures similarity between template and overlapped windows in the source image and fills the resultant image with the measurements.

Retrieves quadrangle from the input array.

Retrieves the rectangular image region with specified center from the input array.

Calculates 7 Hu's invariants from precalculated spatial and central moments.

Calculates all spatial and central moments up to the 3rd order.

Performs complex morphological transformation.

dilates input image (applies maximum filter) one or more times.

erodes input image (applies minimum filter) one or more times.

releases structuring element

Computes the original (undistorted) feature coordinates from the observed (distorted) coordinates.

Computes undistortion+rectification map for a head of stereo camera.

Computes transformation map from intrinsic camera parameters that can used by cvRemap.

Transforms the input image to compensate lens distortion.

Performs forward or inverse linear-polar image transform.

Performs forward or inverse log-polar image transform.

Converts mapx & mapy from floating-point to integer formats for cvRemap.

Performs generic geometric transformation using the specified coordinate maps.

Warps image with perspective (projective) transform.

Warps image with affine transform.

Resizes image (input array is resized to fit the destination array)

Converts input array pixels from one color space to another.

Calculates the image Laplacian: (d2/dx + d2/dy)I.

Calculates an image derivative using generalized Sobel.

Segments image using seed "markers".

Filters image using meanshift algorithm.

Releases pyramid.

Up-samples image and smoothes the result with gaussian kernel.

Smoothes the input image with gaussian kernel and then down-samples it.

Finds integral image: SUM(X,Y) = sum(x<X,y<Y)I(x,y)

Convolves an image with the kernel.

Smooths the image in one of several ways.

Copies source 2D array inside of the larger destination array and makes a border of the specified type (IPL_BORDER_*) around the copied area.

Adds image to accumulator with weights: acc = acc*(1-alpha) + image*alpha.

Adds a product of two images to accumulator.

Adds squared image to accumulator.

Sets error status and performs some additonal actions (displaying message box, writing message to stderr, terminating application etc.) depending on the current error mode.

Sets error status silently.

Saves an object to a file.

Releases an object.

Unregisters the type.

Registers a new type.

Writes a file node to another file storage.

Reads multiple numbers.

Initializes file node sequence reader.

Initializes the file node sequence reader.

Writes multiple numbers.

Starts the next stream.

Writes an object to file storage.

Writes a comment.

Writes a text string.

Writes a floating-point value.

Writes an integer value.

Finishes writing to a file node collection.

Starts writing a new structure.

Releases file storage.

Makes OpenCV use IPL functions for allocating IplImage and IplROI structures.

Removes contour from tree (together with the contour children).

Inserts sequence into tree with specified "parent" sequence.

Does look-up transformation.

Releases graph scanner.

Remove all vertices and edges from the graph.

Remove edge connecting two vertices.

Removes all the elements from the set.

Removes element from the set by its index.

Reverses order of sequence elements in-place.

Sorts sequence in-place given element comparison function.

Inserts a sequence or array into another sequence.

Removes sequence slice.

Changes sequence reader position.

Initializes sequence reader.

Updates sequence header.

Combination of cvCreateSeq and cvStartAppendToSeq.

Initializes sequence writer.

Removes all the elements from the sequence.

Removes specified sequence element.

Removes several elements from the end of sequence and optionally saves them.

Adds several new elements to the end of sequence.

Removes the first element from sequence and optioanally saves it.

Removes the last element from sequence and optionally saves it.

Changes default size (granularity) of sequence blocks.

Restore a storage "free memory" position.

Remember a storage "free memory" position.

Clears memory storage.

Releases memory storage.

Discrete Cosine Transform.

Multiply results of DFTs: DFT(X)*DFT(Y) or DFT(X)*conj(DFT(Y))

Discrete Fourier Transform: complex->complex, real->ccs (forward), ccs->real (inverse)

Finds global minimum, maximum and their positions.

Calculates mean and standard deviation of pixel values.

Calculates covariation matrix for a set of vectors.

* Finds selected eigen values and vectors of a symmetric matrix */

Finds eigen values and vectors of a symmetric matrix.

Performs Singular Value Back Substitution (solves A*X = B): flags must be the same as in cvSVD.

Performs Singular Value Decomposition of a matrix.

Mirror array data around horizontal (flip=0), vertical (flip=1) or both(flip=-1) axises: cvFlip(src) flips images vertically and sequences horizontally (inplace)

Completes the symmetric matrix from the lower (LtoR=0) or from the upper (LtoR!=0) part.

Tranposes matrix.

Calculates (A-delta)*(A-delta)^T (order=0) or (A-delta)^T*(A-delta) (order=1)

Does perspective transform on every element of input array.

Transforms each element of source array and stores resultant vectors in destination array.

Extended matrix transform: dst = alpha*op(A)*op(B) + beta*op(C), where op(X) is X or X^T.

Calculates the cross product of two 3D vectors.

Finds all real and complex roots of a polynomial equation.

Fills an array with random numbers and updates the RNG state.

Calculates natural logarithms: dst(idx) = log(abs(src(idx))).

Does exponention: dst(idx) = exp(src(idx)).

Does powering: dst(idx) = src(idx)^power.

Does polar->cartesian coordinates conversion.

Does cartesian->polar coordinates conversion.

dst(x,y,c) = abs(src(x,y,c) - value(c))

dst(x,y,c) = abs(src1(x,y,c) - src2(x,y,c))

dst(idx) = max(src(idx),value)

dst(idx) = min(src(idx),value)

dst(idx) = max(src1(idx),src2(idx))

dst(idx) = min(src1(idx),src2(idx))

dst(idx) = src1(idx) _cmp_op_ value

The comparison operation support single-channel arrays only.

dst(idx) = lower <= src(idx) < upper

dst(idx) = lower(idx) <= src(idx) < upper(idx)

dst(idx) = ~src(idx)

dst(idx) = src(idx) ^ value

dst(idx) = src1(idx) ^ src2(idx)

dst(idx) = src(idx) | value

dst(idx) = src1(idx) | src2(idx)

dst(idx) = src(idx) & value

dst(idx) = src1(idx) & src2(idx)

dst = src1 * alpha + src2 * beta + gamma

dst = src1 * scale + src2

element-wise division/inversion with scaling: dst(idx) = src1(idx) * scale / src2(idx) or dst(idx) = scale / src2(idx) if src1 == 0

dst(idx) = src1(idx) * src2(idx) * scale (scaled element-wise multiplication of 2 arrays)

dst(mask) = value - src(mask)

dst(mask) = src1(mask) - src2(mask)

dst(mask) = src(mask) + value

dst(mask) = src1(mask) + src2(mask)

Performs linear transformation on every source array element, stores absolute value of the result: dst(x,y,c) = abs(scale*src(x,y,c)+shift).

Converts one array to another with optional linear transformation.

Copies several channels from input arrays to certain channels of output arrays.

Merges a set of single-channel arrays into the single multi-channel array or inserts one particular [color] plane to the array.

Splits a multi-channel array into the set of single-channel arrays or extracts particular [color] plane.

Clears the array.

Sets every element of an array to a given value.

Copies one array to another.

Retrieves low-level information about the array.

Assigns user data to the array header.

Releases array data.

Allocates array data.

Repeats source 2d array several times in both horizontal and vertical direction to fill destination array.

clears element of ND dense array, in case of sparse arrays it deletes the specified node

Change a specific array element.

Change the particular array element.

Deallocates sparse array.

low-level scalar <-> raw data conversion functions

Deallocates a matrix.

Resets the image ROI to include the entire image and releases the ROI structure.

Sets an image Region Of Interest (ROI) for a given rectangle.

Sets the channel of interest in an IplImage.

Deallocates the image header and the image data.

This call is an analogue of :

    if(image )
    {
        iplDeallocate(*image, IPL_IMAGE_HEADER | IPL_IMAGE_ROI);
        *image = 0;
    }

but it does not use IPL functions by default (see the CV_TURN_ON_IPL_COMPATIBILITY macro).

Parameters:
imageDouble pointer to the image header

This call is a shortened form of :

    if(*image )
    {
        cvReleaseData(*image);
        cvReleaseImageHeader(image);
    }
Parameters:
imageDouble pointer to the image header

If the ROI is set to NULL and the coi is *not* 0, the ROI is allocated. Most OpenCV functions do not* support the COI setting, so to process an individual image/matrix channel one may copy (via cvCopy or cvSplit) the channel to a separate image/matrix, process it and then copy the result back (via cvCopy or cvMerge) if needed.

Parameters:
imageA pointer to the image header
coiThe channel of interest. 0 - all channels are selected, 1 - first channel is selected, etc. Note that the channel indices become 1-based.

If the original image ROI was NULL and the rect is not the whole image, the ROI structure is allocated.

Most OpenCV functions support the use of ROI and treat the image rectangle as a separate image. For example, all of the pixel coordinates are counted from the top-left (or bottom-left) corner of the ROI, not the original image.

Parameters:
imageA pointer to the image header
rectThe ROI rectangle

This produces a similar result to the following, but in addition it releases the ROI structure. :

    cvSetImageROI(image, cvRect(0, 0, image->width, image->height ));
    cvSetImageCOI(image, 0);
Parameters:
imageA pointer to the image header

The function decrements the matrix data reference counter and deallocates matrix header. If the data reference counter is 0, it also deallocates the data. :

    if(*mat )
        cvDecRefData(*mat);
    cvFree((void**)mat);
Parameters:
matDouble pointer to the matrix

The function releases the sparse array and clears the array pointer upon exit.

Parameters:
matDouble pointer to the array

The functions assign the new value to a particular array element. In the case of a sparse array the functions create the node if it does not exist yet.

Parameters:
arrInput array
idx0The first zero-based component of the element index
valueThe assigned value

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
arrInput array
idxArray of the element indices
valueThe assigned value

The functions assign a new value to a specific element of a single-channel array. If the array has multiple channels, a runtime error is raised. Note that the Set\*D function can be used safely for both single-channel and multiple-channel arrays, though they are a bit slower.

In the case of a sparse array the functions create the node if it does not yet exist.

Parameters:
arrInput array
idx0The first zero-based component of the element index
valueThe assigned value

The function allocates image, matrix or multi-dimensional dense array data. Note that in the case of matrix types OpenCV allocation functions are used. In the case of IplImage they are used unless CV_TURN_ON_IPL_COMPATIBILITY() has been called before. In the latter case IPL functions are used to allocate the data.

Parameters:
arrArray header

The function releases the array data. In the case of CvMat or CvMatND it simply calls cvDecRefData(), that is the function can not deallocate external data. See also the note to cvCreateData .

Parameters:
arrArray header

The function assigns user data to the array header. Header should be initialized before using cvCreateMatHeader, cvCreateImageHeader, cvCreateMatNDHeader, cvInitMatHeader, cvInitImageHeader or cvInitMatNDHeader.

Parameters:
arrArray header
dataUser data
stepFull row length in bytes

The function fills output variables with low-level information about the array data. All output

parameters are optional, so some of the pointers may be set to NULL. If the array is IplImage with ROI set, the parameters of ROI are returned.

The following example shows how to get access to array elements. It computes absolute values of the array elements :

    float* data;
    int step;
    CvSize size;

    cvGetRawData(array, (uchar**)&data, &step, &size);
    step /= sizeof(data[0]);

    for(int y = 0; y < size.height; y++, data += step )
        for(int x = 0; x < size.width; x++ )
            data[x] = (float)fabs(data[x]);
Parameters:
arrArray header
dataOutput pointer to the whole image origin or ROI origin if ROI is set
stepOutput full row length in bytes
roi_sizeOutput ROI size

The function copies selected elements from an input array to an output array:

\[\texttt{dst} (I)= \texttt{src} (I) \quad \text{if} \quad \texttt{mask} (I) \ne 0.\]

If any of the passed arrays is of IplImage type, then its ROI and COI fields are used. Both arrays must have the same type, the same number of dimensions, and the same size. The function can also copy sparse arrays (mask is not supported in this case).

Parameters:
srcThe source array
dstThe destination array
maskOperation mask, 8-bit single channel array; specifies elements of the destination array to be changed

The function copies the scalar value to every selected element of the destination array:

\[\texttt{arr} (I)= \texttt{value} \quad \text{if} \quad \texttt{mask} (I) \ne 0\]

If array arr is of IplImage type, then is ROI used, but COI must not be set.

Parameters:
arrThe destination array
valueFill value
maskOperation mask, 8-bit single channel array; specifies elements of the destination array to be changed

The function clears the array. In the case of dense arrays (CvMat, CvMatND or IplImage), cvZero(array) is equivalent to cvSet(array,cvScalarAll(0),0). In the case of sparse arrays all the elements are removed.

Parameters:
arrArray to be cleared

The function has several different purposes, and thus has several different names. It copies one array to another with optional scaling, which is performed first, and/or optional type conversion, performed after:

\[\texttt{dst} (I) = \texttt{scale} \texttt{src} (I) + ( \texttt{shift} _0, \texttt{shift} _1,...)\]

All the channels of multi-channel arrays are processed independently.

The type of conversion is done with rounding and saturation, that is if the result of scaling + conversion can not be represented exactly by a value of the destination array element type, it is set to the nearest representable value on the real axis.

Parameters:
srcSource array
dstDestination array
scaleScale factor
shiftValue added to the scaled source array elements

destination array must have 8u type. In other cases one may use cvConvertScale + cvAbsDiffS

Destination image should be 8uC1 or 8sC1 dst(idx) = src1(idx) _cmp_op_ src2(idx)

Either of output components (magnitude or angle) is optional

Either of output components (magnitude or angle) is optional. If magnitude is missing it is assumed to be all 1's

Overflow is not handled yet. Underflow is handled. Maximal relative error is ~7e-6 for single-precision input

Logarithm of 0 gives large negative number(~-700) Maximal relative error is ~3e-7 for single-precision output

The function fills the destination array with uniformly or normally distributed random numbers.

Parameters:
rngCvRNG state initialized by cvRNG
arrThe destination array
dist_typeDistribution type > - **CV_RAND_UNI** uniform distribution > - **CV_RAND_NORMAL** normal or Gaussian distribution
param1The first parameter of the distribution. In the case of a uniform distribution it is the inclusive lower boundary of the random numbers range. In the case of a normal distribution it is the mean value of the random numbers.
param2The second parameter of the distribution. In the case of a uniform distribution it is the exclusive upper boundary of the random numbers range. In the case of a normal distribution it is the standard deviation of the random numbers.
See also:
randu, randn, RNG::fill.

The function calculates the cross product of two 3D vectors:

\[\texttt{dst} = \texttt{src1} \times \texttt{src2}\]

or:

\[\begin{array}{l} \texttt{dst} _1 = \texttt{src1} _2 \texttt{src2} _3 - \texttt{src1} _3 \texttt{src2} _2 \\ \texttt{dst} _2 = \texttt{src1} _3 \texttt{src2} _1 - \texttt{src1} _1 \texttt{src2} _3 \\ \texttt{dst} _3 = \texttt{src1} _1 \texttt{src2} _2 - \texttt{src1} _2 \texttt{src2} _1 \end{array}\]

Parameters:
src1The first source vector
src2The second source vector
dstThe destination vector

Square matrices can be transposed in-place

Makes an identity matrix (mat_ij = i == j)

See also:
flags
ref core_c_NormFlags "flags"
flags
core_c_DftFlags "flags"

All the children of a parent must be released before the parent. A child storage returns all the blocks to parent when it is released

This is the only way(!!!) (besides cvRestoreMemStoragePos) to reuse memory allocated for the storage - cvClearSeq,cvClearSet ... do not free any memory. A child storage returns all the blocks to the parent when it is cleared

The default size is ~1Kbyte

The freed memory can be reused later only by the same sequence unless cvClearMemStorage or cvRestoreMemStoragePos is called

The new elements will be added to the end of sequence

May be useful to get access to some of previously written elements via cvGetSeqElem or sequence reader

The sequence can be read in forward or backward direction

It may seek to an absolute or to relative to the current position

Elements of the source array (that should be 8uC1 or 8sC1) are used as indexes in lutarr 256-element table

If parent is equal to frame (e.g. the most external contour), then added contour will have null pointer to parent.

Normally, the function is not called directly. Instead, a simple macro CV_TURN_ON_IPL_COMPATIBILITY() is used that calls cvSetIPLAllocators and passes there pointers to IPL allocation functions. :

    ...
    CV_TURN_ON_IPL_COMPATIBILITY()
    ...
Parameters:
create_headerpointer to a function, creating IPL image header.
allocate_datapointer to a function, allocating IPL image data.
deallocatepointer to a function, deallocating IPL image.
create_roipointer to a function, creating IPL image ROI (i.e. Region of Interest).
clone_imagepointer to a function, cloning an IPL image.

The function closes the file associated with the storage and releases all the temporary structures. It must be called after all I/O operations with the storage are finished.

Parameters:
fsDouble pointer to the released file storage

The function starts writing a compound structure (collection) that can be a sequence or a map. After all the structure fields, which can be scalars or structures, are written, cvEndWriteStruct should be called. The function can be used to group some objects or to implement the write function for a some user object (see CvTypeInfo).

Parameters:
fsFile storage
nameName of the written structure. The structure can be accessed by this name when the storage is read.
struct_flagsA combination one of the following values:

  • **CV_NODE_SEQ** the written structure is a sequence (see discussion of CvFileStorage ), that is, its elements do not have a name.
  • **CV_NODE_MAP** the written structure is a map (see discussion of CvFileStorage ), that is, all its elements have names. One and only one of the two above flags must be specified
  • **CV_NODE_FLOW** the optional flag that makes sense only for YAML streams. It means that the structure is written as a flow (not as a block), which is more compact. It is recommended to use this flag for structures or arrays whose elements are all scalars.
type_nameOptional parameter - the object type name. In case of XML it is written as a type_id attribute of the structure opening tag. In the case of YAML it is written after a colon following the structure name (see the example in CvFileStorage description). Mainly it is used with user objects. When the storage is read, the encoded type name is used to determine the object type (see CvTypeInfo and cvFindType ).
attributesThis parameter is not used in the current implementation
fsFile storage
See also:
cvStartWriteStruct.

The function writes a single integer value (with or without a name) to the file storage.

Parameters:
fsFile storage
nameName of the written value. Should be NULL if and only if the parent structure is a sequence.
valueThe written value

The function writes a single floating-point value (with or without a name) to file storage. Special values are encoded as follows: NaN (Not A Number) as .NaN, infinity as +.Inf or -.Inf.

The following example shows how to use the low-level writing functions to store custom structures, such as termination criteria, without registering a new type. :

    void write_termcriteria( CvFileStorage* fs, const char* struct_name,
                             CvTermCriteria * termcrit )
    {
        cvStartWriteStruct( fs, struct_name, CV_NODE_MAP, NULL, cvAttrList(0,0));
        cvWriteComment( fs, "termination criteria", 1 ); // just a description
        if( termcrit->type & CV_TERMCRIT_ITER )
            cvWriteInteger( fs, "max_iterations", termcrit->max_iter );
        if( termcrit->type & CV_TERMCRIT_EPS )
            cvWriteReal( fs, "accuracy", termcrit->epsilon );
        cvEndWriteStruct( fs );
    }
Parameters:
fsFile storage
nameName of the written value. Should be NULL if and only if the parent structure is a sequence.
valueThe written value

The function writes a text string to file storage.

Parameters:
fsFile storage
nameName of the written string . Should be NULL if and only if the parent structure is a sequence.
strThe written text string
quoteIf non-zero, the written string is put in quotes, regardless of whether they are required. Otherwise, if the flag is zero, quotes are used only when they are required (e.g. when the string starts with a digit or contains spaces).

The function writes a comment into file storage. The comments are skipped when the storage is read.

Parameters:
fsFile storage
commentThe written comment, single-line or multi-line
eol_commentIf non-zero, the function tries to put the comment at the end of current line. If the flag is zero, if the comment is multi-line, or if it does not fit at the end of the current line, the comment starts a new line.

The function writes an object to file storage. First, the appropriate type info is found using cvTypeOf. Then, the write method associated with the type info is called.

Attributes are used to customize the writing procedure. The standard types support the following attributes (all the dt attributes have the same format as in cvWriteRawData):

  1. CvSeq
    • **header_dt** description of user fields of the sequence header that follow CvSeq, or CvChain (if the sequence is a Freeman chain) or CvContour (if the sequence is a contour or point sequence)
    • **dt** description of the sequence elements.
    • **recursive** if the attribute is present and is not equal to "0" or "false", the whole tree of sequences (contours) is stored.
  2. CvGraph
    • **header_dt** description of user fields of the graph header that follows CvGraph;
    • **vertex_dt** description of user fields of graph vertices
    • **edge_dt** description of user fields of graph edges (note that the edge weight is always written, so there is no need to specify it explicitly)

Below is the code that creates the YAML file shown in the CvFileStorage description:

    #include "cxcore.h"

    int main( int argc, char** argv )
    {
        CvMat* mat = cvCreateMat( 3, 3, CV_32F );
        CvFileStorage* fs = cvOpenFileStorage( "example.yml", 0, CV_STORAGE_WRITE );

        cvSetIdentity( mat );
        cvWrite( fs, "A", mat, cvAttrList(0,0) );

        cvReleaseFileStorage( &fs );
        cvReleaseMat( &mat );
        return 0;
    }
Parameters:
fsFile storage
nameName of the written object. Should be NULL if and only if the parent structure is a sequence.
ptrPointer to the object
attributesThe attributes of the object. They are specific for each particular type (see the discussion below).

The function finishes the currently written stream and starts the next stream. In the case of XML the file with multiple streams looks like this:

 {.xml}
    <opencv_storage>
    <!-- stream #1 data -->
    </opencv_storage>
    <opencv_storage>
    <!-- stream #2 data -->
    </opencv_storage>
    ...

The YAML file will look like this:

 {.yaml}
    %YAML:1.0
    # stream #1 data
    ...
    ---
    # stream #2 data

This is useful for concatenating files or for resuming the writing process.

Parameters:
fsFile storage

The function writes an array, whose elements consist of single or multiple numbers. The function call can be replaced with a loop containing a few cvWriteInt and cvWriteReal calls, but a single call is more efficient. Note that because none of the elements have a name, they should be written to a sequence rather than a map.

Parameters:
fsFile storage
srcPointer to the written array
lenNumber of the array elements to write
dtSpecification of each array element, see format specification

The function initializes the sequence reader to read data from a file node. The initialized reader can be then passed to cvReadRawDataSlice.

Parameters:
fsFile storage
srcThe file node (a sequence) to read numbers from
readerPointer to the sequence reader

The function reads one or more elements from the file node, representing a sequence, to a user-specified array. The total number of read sequence elements is a product of total and the number of components in each array element. For example, if dt=2if, the function will read total\*3 sequence elements. As with any sequence, some parts of the file node sequence can be skipped or read repeatedly by repositioning the reader using cvSetSeqReaderPos.

Parameters:
fsFile storage
readerThe sequence reader. Initialize it with cvStartReadRawData .
countThe number of elements to read
dstPointer to the destination array
dtSpecification of each array element. It has the same format as in cvWriteRawData .

The function reads elements from a file node that represents a sequence of scalars.

Parameters:
fsFile storage
srcThe file node (a sequence) to read numbers from
dstPointer to the destination array
dtSpecification of each array element. It has the same format as in cvWriteRawData .

The function writes a copy of a file node to file storage. Possible applications of the function are merging several file storages into one and conversion between XML and YAML formats.

Parameters:
fsDestination file storage
new_node_nameNew name of the file node in the destination file storage. To keep the existing name, use cvcvGetFileNodeName
nodeThe written node
embedIf the written node is a collection and this parameter is not zero, no extra level of hierarchy is created. Instead, all the elements of node are written into the currently written structure. Of course, map elements can only be embedded into another map, and sequence elements can only be embedded into another sequence.

The function registers a new type, which is described by info . The function creates a copy of the structure, so the user should delete it after calling the function.

Parameters:
infoType info structure

The function unregisters a type with a specified name. If the name is unknown, it is possible to locate the type info by an instance of the type using cvTypeOf or by iterating the type list, starting from cvFirstType, and then calling cvUnregisterType(info->typeName).

Parameters:
type_nameName of an unregistered type

The function finds the type of a given object and calls release with the double pointer.

Parameters:
struct_ptrDouble pointer to the object

The function saves an object to a file. It provides a simple interface to cvWrite .

Parameters:
filenameFile name
struct_ptrObject to save
nameOptional object name. If it is NULL, the name will be formed from filename .
commentOptional comment to put in the beginning of the file
attributesOptional attributes passed to cvWrite
See also:
cv::accumulateSquare
cv::accumulateProduct
cv::accumulateWeighted
Parameters:
srcThe source image
dstThe destination image
smoothtypeType of the smoothing, see SmoothMethod_c
size1The first parameter of the smoothing operation, the aperture width. Must be a positive odd number (1, 3, 5, ...)
size2The second parameter of the smoothing operation, the aperture height. Ignored by CV_MEDIAN and CV_BILATERAL methods. In the case of simple scaled/non-scaled and Gaussian blur if size2 is zero, it is set to size1. Otherwise it must be a positive odd number.
sigma1In the case of a Gaussian parameter this parameter may specify Gaussian $\sigma$ (standard deviation). If it is zero, it is calculated from the kernel size:

\[\sigma = 0.3 (n/2 - 1) + 0.8 \quad \text{where} \quad n= \begin{array}{l l} \mbox{\texttt{size1} for horizontal kernel} \\ \mbox{\texttt{size2} for vertical kernel} \end{array}\]

Using standard sigma for small kernels ( $3\times 3$ to $7\times 7$ ) gives better speed. If sigma1 is not zero, while size1 and size2 are zeros, the kernel size is calculated from the sigma (to provide accurate enough operation).

sigma2additional parameter for bilateral filtering
See also:
cv::GaussianBlur, cv::blur, cv::medianBlur, cv::bilateralFilter.
Parameters:
srcinput image.
dstoutput image of the same size and the same number of channels as src.
kernelconvolution kernel (or rather a correlation kernel), a single-channel floating point matrix; if you want to apply different kernels to different channels, split the image into separate color planes using split and process them individually.
anchoranchor of the kernel that indicates the relative position of a filtered point within the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor is at the kernel center.
See also:
cv::filter2D
cv::integral

dst_width = floor(src_width/2)[+1], dst_height = floor(src_height/2)[+1]

See also:
cv::pyrDown

dst_width = src_width*2, dst_height = src_height*2

See also:
cv::pyrUp
cv::pyrMeanShiftFiltering
cv::watershed

(aperture_size = 1,3,5,7) or Scharr (aperture_size = -1) operator. Scharr can be used only for the first dx or dy derivative

See also:
cv::Sobel
cv::Laplacian
cv::cvtColor
cv::resize
Note:
cvGetQuadrangleSubPix is similar to cvWarpAffine, but the outliers are extrapolated using replication border mode.
See also:
cv::warpAffine
cv::warpPerspective
cv::remap
cv::convertMaps
cv::logPolar
cv::linearPolar
cv::undistort
cv::initUndistortRectifyMap
cv::undistortPoints
cvCreateStructuringElementEx

If element pointer is NULL, 3x3 rectangular element is used

See also:
cv::erode

If element pointer is NULL, 3x3 rectangular element is used

See also:
cv::dilate
cv::morphologyEx
cv::moments
cv::HuMoments

dst(x,y) <- src(x + center.x - dst_width/2, y + center.y - dst_height/2). Values of pixels with fractional coordinates are retrieved using bilinear interpolation

See also:
cv::getRectSubPix

matrixarr = ( a11 a12 | b1 ) dst(x,y) <- src(A[x y]' + b) ( a21 a22 | b2 ) (bilinear interpolation is used to retrieve pixels with fractional coordinates)

See also:
cvWarpAffine
cv::matchTemplate

(if the substitutor is null, the last retrieved contour is removed from the tree)

See also:
cvFindContours

The reader is used to iteratively get coordinates of all the chain points. If the Freeman codes should be read as is, a simple sequence reader should be used

See also:
cvApproxChains

This is a standalone function for setting bin ranges in the histogram. For a more detailed description of the parameters ranges and uniform, see the :ocvCalcHist function that can initialize the ranges as well. Ranges for the histogram bins must be set before the histogram is calculated or the backproject of the histogram is calculated.

Parameters:
histHistogram.
rangesArray of bin ranges arrays. See :ocvCreateHist for details.
uniformUniformity flag. See :ocvCreateHist for details.

The function releases the histogram (header and the data). The pointer to the histogram is cleared by the function. If \*hist pointer is already NULL, the function does nothing.

Parameters:
histDouble pointer to the released histogram.

The function sets all of the histogram bins to 0 in case of a dense histogram and removes all histogram bins in case of a sparse array.

Parameters:
histHistogram.

The function finds the minimum and maximum histogram bins and their positions. All of output arguments are optional. Among several extremas with the same value the ones with the minimum index (in the lexicographical order) are returned. In case of several maximums or minimums, the earliest in the lexicographical order (extrema locations) is returned.

Parameters:
histHistogram.
min_valuePointer to the minimum value of the histogram.
max_valuePointer to the maximum value of the histogram.
min_idxPointer to the array of coordinates for the minimum.
max_idxPointer to the array of coordinates for the maximum.

The function normalizes the histogram bins by scaling them so that the sum of the bins becomes equal to factor.

Parameters:
histPointer to the histogram.
factorNormalization factor.

The function clears histogram bins that are below the specified threshold.

Parameters:
histPointer to the histogram.
thresholdThreshold level.

The function makes a copy of the histogram. If the second histogram pointer \*dst is NULL, a new histogram of the same size as src is created. Otherwise, both histograms must have equal types and sizes. Then the function copies the bin values of the source histogram to the destination histogram and sets the same bin value ranges as in src.

Parameters:
srcSource histogram.
dstPointer to the destination histogram.
See also:
cv::calcHist
cvCalcBackProject, cv::calcBackProject

The function calculates the back projection by comparing histograms of the source image patches with the given histogram. The function is similar to matchTemplate, but instead of comparing the raster patch with all its possible positions within the search window, the function CalcBackProjectPatch compares histograms. See the algorithm diagram below:

![image](pics/backprojectpatch.png)

Parameters:
imageSource images (though, you may pass CvMat\*\* as well).
dstDestination image.
range
histHistogram.
methodComparison method passed to cvCompareHist (see the function description).
factorNormalization factor for histograms that affects the normalization scale of the destination image. Pass 1 if not sure.
See also:
cvCalcBackProjectPatch

The function calculates the object probability density from two histograms as:

\[\texttt{disthist} (I)= \forkthree{0}{if \(\texttt{hist1}(I)=0\)}{\texttt{scale}}{if \(\texttt{hist1}(I) \ne 0\) and \(\texttt{hist2}(I) > \texttt{hist1}(I)\)}{\frac{\texttt{hist2}(I) \cdot \texttt{scale}}{\texttt{hist1}(I)}}{if \(\texttt{hist1}(I) \ne 0\) and \(\texttt{hist2}(I) \le \texttt{hist1}(I)\)}\]

Parameters:
hist1First histogram (the divisor).
hist2Second histogram.
dst_histDestination histogram.
scaleScale factor for the destination histogram.
See also:
cv::equalizeHist
cv::distanceTransform

The two parameters for methods CV_ADAPTIVE_THRESH_MEAN_C and CV_ADAPTIVE_THRESH_GAUSSIAN_C are: neighborhood size (3, 5, 7 etc.), and a constant subtracted from mean (...,-3,-2,-1,0,1,2,3,...)

See also:
cv::adaptiveThreshold
cv::floodFill
cv::Canny

Dx^2 * Dyy + Dxx * Dy^2 - 2 * Dx * Dy * Dxy. Applying threshold to the result gives coordinates of corners

See also:
cv::preCornerDetect
cv::cornerEigenValsAndVecs
cv::cornerMinEigenVal

Calculates det(M) - k*(trace(M)^2), where M is 2x2 gradient covariation matrix for each pixel

See also:
cv::cornerHarris
cv::cornerSubPix
cv::goodFeaturesToTrack
cv::fitLine
cv::line

if thickness<0 (e.g. thickness == CV_FILLED), the filled box is drawn

See also:
cv::rectangle
cv::rectangle

Thickness works in the same way as with cvRectangle

See also:
cv::circle

depending on _thickness_, _start_angle_ and _end_angle_ parameters. The resultant figure is rotated by _angle_. All the angles are in degrees

See also:
cv::ellipse
cv::fillConvexPoly
cv::fillPoly
cv::polylines

The function initializes the font structure that can be passed to text rendering functions.

Parameters:
fontPointer to the font structure initialized by the function
font_faceFont name identifier. See cv::HersheyFonts and corresponding old CV_* identifiers.
hscaleHorizontal scale. If equal to 1.0f , the characters have the original width depending on the font type. If equal to 0.5f , the characters are of half the original width.
vscaleVertical scale. If equal to 1.0f , the characters have the original height depending on the font type. If equal to 0.5f , the characters are of half the original height.
shearApproximate tangent of the character slope relative to the vertical line. A zero value means a non-italic font, 1.0f means about a 45 degree slope, etc.
thicknessThickness of the text strokes
line_typeType of the strokes, see line description
See also:
cvPutText

CvFont should be initialized with cvInitFont

See also:
cvInitFont, cvGetTextSize, cvFont, cv::putText
cv::getTextSize
cv::drawContours

Sets error status and performs some additonal actions (displaying message box, writing message to stderr, terminating application etc.) depending on the current error mode.

Sets error status silently.

Saves an object to a file.

Releases an object.

Unregisters the type.

Registers a new type.

Writes a file node to another file storage.

Reads multiple numbers.

Initializes file node sequence reader.

Initializes the file node sequence reader.

Writes multiple numbers.

Starts the next stream.

Writes an object to file storage.

Writes a comment.

Writes a text string.

Writes a floating-point value.

Writes an integer value.

Finishes writing to a file node collection.

Starts writing a new structure.

Releases file storage.

Makes OpenCV use IPL functions for allocating IplImage and IplROI structures.

Removes contour from tree (together with the contour children).

Inserts sequence into tree with specified "parent" sequence.

Does look-up transformation.

Releases graph scanner.

Remove all vertices and edges from the graph.

Remove edge connecting two vertices.

Removes all the elements from the set.

Removes element from the set by its index.

Reverses order of sequence elements in-place.

Sorts sequence in-place given element comparison function.

Inserts a sequence or array into another sequence.

Removes sequence slice.

Changes sequence reader position.

Initializes sequence reader.

Updates sequence header.

Combination of cvCreateSeq and cvStartAppendToSeq.

Initializes sequence writer.

Removes all the elements from the sequence.

Removes specified sequence element.

Removes several elements from the end of sequence and optionally saves them.

Adds several new elements to the end of sequence.

Removes the first element from sequence and optioanally saves it.

Removes the last element from sequence and optionally saves it.

Changes default size (granularity) of sequence blocks.

Restore a storage "free memory" position.

Remember a storage "free memory" position.

Clears memory storage.

Releases memory storage.

Discrete Cosine Transform.

Multiply results of DFTs: DFT(X)*DFT(Y) or DFT(X)*conj(DFT(Y))

Discrete Fourier Transform: complex->complex, real->ccs (forward), ccs->real (inverse)

Finds global minimum, maximum and their positions.

Calculates mean and standard deviation of pixel values.

Calculates covariation matrix for a set of vectors.

* Finds selected eigen values and vectors of a symmetric matrix */

Finds eigen values and vectors of a symmetric matrix.

Performs Singular Value Back Substitution (solves A*X = B): flags must be the same as in cvSVD.

Performs Singular Value Decomposition of a matrix.

Mirror array data around horizontal (flip=0), vertical (flip=1) or both(flip=-1) axises: cvFlip(src) flips images vertically and sequences horizontally (inplace)

Completes the symmetric matrix from the lower (LtoR=0) or from the upper (LtoR!=0) part.

Tranposes matrix.

Calculates (A-delta)*(A-delta)^T (order=0) or (A-delta)^T*(A-delta) (order=1)

Does perspective transform on every element of input array.

Transforms each element of source array and stores resultant vectors in destination array.

Extended matrix transform: dst = alpha*op(A)*op(B) + beta*op(C), where op(X) is X or X^T.

Calculates the cross product of two 3D vectors.

Finds all real and complex roots of a polynomial equation.

Fills an array with random numbers and updates the RNG state.

Calculates natural logarithms: dst(idx) = log(abs(src(idx))).

Does exponention: dst(idx) = exp(src(idx)).

Does powering: dst(idx) = src(idx)^power.

Does polar->cartesian coordinates conversion.

Does cartesian->polar coordinates conversion.

dst(x,y,c) = abs(src(x,y,c) - value(c))

dst(x,y,c) = abs(src1(x,y,c) - src2(x,y,c))

dst(idx) = max(src(idx),value)

dst(idx) = min(src(idx),value)

dst(idx) = max(src1(idx),src2(idx))

dst(idx) = min(src1(idx),src2(idx))

dst(idx) = src1(idx) _cmp_op_ value

The comparison operation support single-channel arrays only.

dst(idx) = lower <= src(idx) < upper

dst(idx) = lower(idx) <= src(idx) < upper(idx)

dst(idx) = ~src(idx)

dst(idx) = src(idx) ^ value

dst(idx) = src1(idx) ^ src2(idx)

dst(idx) = src(idx) | value

dst(idx) = src1(idx) | src2(idx)

dst(idx) = src(idx) & value

dst(idx) = src1(idx) & src2(idx)

dst = src1 * alpha + src2 * beta + gamma

dst = src1 * scale + src2

element-wise division/inversion with scaling: dst(idx) = src1(idx) * scale / src2(idx) or dst(idx) = scale / src2(idx) if src1 == 0

dst(idx) = src1(idx) * src2(idx) * scale (scaled element-wise multiplication of 2 arrays)

dst(mask) = value - src(mask)

dst(mask) = src1(mask) - src2(mask)

dst(mask) = src(mask) + value

dst(mask) = src1(mask) + src2(mask)

Performs linear transformation on every source array element, stores absolute value of the result: dst(x,y,c) = abs(scale*src(x,y,c)+shift).

Converts one array to another with optional linear transformation.

Copies several channels from input arrays to certain channels of output arrays.

Merges a set of single-channel arrays into the single multi-channel array or inserts one particular [color] plane to the array.

Splits a multi-channel array into the set of single-channel arrays or extracts particular [color] plane.

Clears the array.

Sets every element of an array to a given value.

Copies one array to another.

Retrieves low-level information about the array.

Assigns user data to the array header.

Releases array data.

Allocates array data.

Repeats source 2d array several times in both horizontal and vertical direction to fill destination array.

clears element of ND dense array, in case of sparse arrays it deletes the specified node

Change a specific array element.

Change the particular array element.

Deallocates sparse array.

low-level scalar <-> raw data conversion functions

Deallocates a matrix.

Resets the image ROI to include the entire image and releases the ROI structure.

Sets an image Region Of Interest (ROI) for a given rectangle.

Sets the channel of interest in an IplImage.

Deallocates the image header and the image data.

Deallocates an image header.

Here and further all the memory releasing functions (that all call cvFree) take double pointer in order to to clear pointer to the data after releasing it. Passing pointer to NULL pointer is Ok: nothing happens in this case

This call is an analogue of :

    if(image )
    {
        iplDeallocate(*image, IPL_IMAGE_HEADER | IPL_IMAGE_ROI);
        *image = 0;
    }

but it does not use IPL functions by default (see the CV_TURN_ON_IPL_COMPATIBILITY macro).

Parameters:
imageDouble pointer to the image header

This call is a shortened form of :

    if(*image )
    {
        cvReleaseData(*image);
        cvReleaseImageHeader(image);
    }
Parameters:
imageDouble pointer to the image header

If the ROI is set to NULL and the coi is *not* 0, the ROI is allocated. Most OpenCV functions do not* support the COI setting, so to process an individual image/matrix channel one may copy (via cvCopy or cvSplit) the channel to a separate image/matrix, process it and then copy the result back (via cvCopy or cvMerge) if needed.

Parameters:
imageA pointer to the image header
coiThe channel of interest. 0 - all channels are selected, 1 - first channel is selected, etc. Note that the channel indices become 1-based.

If the original image ROI was NULL and the rect is not the whole image, the ROI structure is allocated.

Most OpenCV functions support the use of ROI and treat the image rectangle as a separate image. For example, all of the pixel coordinates are counted from the top-left (or bottom-left) corner of the ROI, not the original image.

Parameters:
imageA pointer to the image header
rectThe ROI rectangle

This produces a similar result to the following, but in addition it releases the ROI structure. :

    cvSetImageROI(image, cvRect(0, 0, image->width, image->height ));
    cvSetImageCOI(image, 0);
Parameters:
imageA pointer to the image header

The function decrements the matrix data reference counter and deallocates matrix header. If the data reference counter is 0, it also deallocates the data. :

    if(*mat )
        cvDecRefData(*mat);
    cvFree((void**)mat);
Parameters:
matDouble pointer to the matrix

The function releases the sparse array and clears the array pointer upon exit.

Parameters:
matDouble pointer to the array

The functions assign the new value to a particular array element. In the case of a sparse array the functions create the node if it does not exist yet.

Parameters:
arrInput array
idx0The first zero-based component of the element index
valueThe assigned value

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
arrInput array
idxArray of the element indices
valueThe assigned value

The functions assign a new value to a specific element of a single-channel array. If the array has multiple channels, a runtime error is raised. Note that the Set\*D function can be used safely for both single-channel and multiple-channel arrays, though they are a bit slower.

In the case of a sparse array the functions create the node if it does not yet exist.

Parameters:
arrInput array
idx0The first zero-based component of the element index
valueThe assigned value

The function allocates image, matrix or multi-dimensional dense array data. Note that in the case of matrix types OpenCV allocation functions are used. In the case of IplImage they are used unless CV_TURN_ON_IPL_COMPATIBILITY() has been called before. In the latter case IPL functions are used to allocate the data.

Parameters:
arrArray header

The function releases the array data. In the case of CvMat or CvMatND it simply calls cvDecRefData(), that is the function can not deallocate external data. See also the note to cvCreateData .

Parameters:
arrArray header

The function assigns user data to the array header. Header should be initialized before using cvCreateMatHeader, cvCreateImageHeader, cvCreateMatNDHeader, cvInitMatHeader, cvInitImageHeader or cvInitMatNDHeader.

Parameters:
arrArray header
dataUser data
stepFull row length in bytes

The function fills output variables with low-level information about the array data. All output

parameters are optional, so some of the pointers may be set to NULL. If the array is IplImage with ROI set, the parameters of ROI are returned.

The following example shows how to get access to array elements. It computes absolute values of the array elements :

    float* data;
    int step;
    CvSize size;

    cvGetRawData(array, (uchar**)&data, &step, &size);
    step /= sizeof(data[0]);

    for(int y = 0; y < size.height; y++, data += step )
        for(int x = 0; x < size.width; x++ )
            data[x] = (float)fabs(data[x]);
Parameters:
arrArray header
dataOutput pointer to the whole image origin or ROI origin if ROI is set
stepOutput full row length in bytes
roi_sizeOutput ROI size

The function copies selected elements from an input array to an output array:

\[\texttt{dst} (I)= \texttt{src} (I) \quad \text{if} \quad \texttt{mask} (I) \ne 0.\]

If any of the passed arrays is of IplImage type, then its ROI and COI fields are used. Both arrays must have the same type, the same number of dimensions, and the same size. The function can also copy sparse arrays (mask is not supported in this case).

Parameters:
srcThe source array
dstThe destination array
maskOperation mask, 8-bit single channel array; specifies elements of the destination array to be changed

The function copies the scalar value to every selected element of the destination array:

\[\texttt{arr} (I)= \texttt{value} \quad \text{if} \quad \texttt{mask} (I) \ne 0\]

If array arr is of IplImage type, then is ROI used, but COI must not be set.

Parameters:
arrThe destination array
valueFill value
maskOperation mask, 8-bit single channel array; specifies elements of the destination array to be changed

The function clears the array. In the case of dense arrays (CvMat, CvMatND or IplImage), cvZero(array) is equivalent to cvSet(array,cvScalarAll(0),0). In the case of sparse arrays all the elements are removed.

Parameters:
arrArray to be cleared

The function has several different purposes, and thus has several different names. It copies one array to another with optional scaling, which is performed first, and/or optional type conversion, performed after:

\[\texttt{dst} (I) = \texttt{scale} \texttt{src} (I) + ( \texttt{shift} _0, \texttt{shift} _1,...)\]

All the channels of multi-channel arrays are processed independently.

The type of conversion is done with rounding and saturation, that is if the result of scaling + conversion can not be represented exactly by a value of the destination array element type, it is set to the nearest representable value on the real axis.

Parameters:
srcSource array
dstDestination array
scaleScale factor
shiftValue added to the scaled source array elements

destination array must have 8u type. In other cases one may use cvConvertScale + cvAbsDiffS

Destination image should be 8uC1 or 8sC1 dst(idx) = src1(idx) _cmp_op_ src2(idx)

Either of output components (magnitude or angle) is optional

Either of output components (magnitude or angle) is optional. If magnitude is missing it is assumed to be all 1's

Overflow is not handled yet. Underflow is handled. Maximal relative error is ~7e-6 for single-precision input

Logarithm of 0 gives large negative number(~-700) Maximal relative error is ~3e-7 for single-precision output

The function fills the destination array with uniformly or normally distributed random numbers.

Parameters:
rngCvRNG state initialized by cvRNG
arrThe destination array
dist_typeDistribution type > - **CV_RAND_UNI** uniform distribution > - **CV_RAND_NORMAL** normal or Gaussian distribution
param1The first parameter of the distribution. In the case of a uniform distribution it is the inclusive lower boundary of the random numbers range. In the case of a normal distribution it is the mean value of the random numbers.
param2The second parameter of the distribution. In the case of a uniform distribution it is the exclusive upper boundary of the random numbers range. In the case of a normal distribution it is the standard deviation of the random numbers.
See also:
randu, randn, RNG::fill.

The function calculates the cross product of two 3D vectors:

\[\texttt{dst} = \texttt{src1} \times \texttt{src2}\]

or:

\[\begin{array}{l} \texttt{dst} _1 = \texttt{src1} _2 \texttt{src2} _3 - \texttt{src1} _3 \texttt{src2} _2 \\ \texttt{dst} _2 = \texttt{src1} _3 \texttt{src2} _1 - \texttt{src1} _1 \texttt{src2} _3 \\ \texttt{dst} _3 = \texttt{src1} _1 \texttt{src2} _2 - \texttt{src1} _2 \texttt{src2} _1 \end{array}\]

Parameters:
src1The first source vector
src2The second source vector
dstThe destination vector

Square matrices can be transposed in-place

Makes an identity matrix (mat_ij = i == j)

See also:
flags
ref core_c_NormFlags "flags"
flags
core_c_DftFlags "flags"

All the children of a parent must be released before the parent. A child storage returns all the blocks to parent when it is released

This is the only way(!!!) (besides cvRestoreMemStoragePos) to reuse memory allocated for the storage - cvClearSeq,cvClearSet ... do not free any memory. A child storage returns all the blocks to the parent when it is cleared

The default size is ~1Kbyte

The freed memory can be reused later only by the same sequence unless cvClearMemStorage or cvRestoreMemStoragePos is called

The new elements will be added to the end of sequence

May be useful to get access to some of previously written elements via cvGetSeqElem or sequence reader

The sequence can be read in forward or backward direction

It may seek to an absolute or to relative to the current position

Elements of the source array (that should be 8uC1 or 8sC1) are used as indexes in lutarr 256-element table

If parent is equal to frame (e.g. the most external contour), then added contour will have null pointer to parent.

Normally, the function is not called directly. Instead, a simple macro CV_TURN_ON_IPL_COMPATIBILITY() is used that calls cvSetIPLAllocators and passes there pointers to IPL allocation functions. :

    ...
    CV_TURN_ON_IPL_COMPATIBILITY()
    ...
Parameters:
create_headerpointer to a function, creating IPL image header.
allocate_datapointer to a function, allocating IPL image data.
deallocatepointer to a function, deallocating IPL image.
create_roipointer to a function, creating IPL image ROI (i.e. Region of Interest).
clone_imagepointer to a function, cloning an IPL image.

The function closes the file associated with the storage and releases all the temporary structures. It must be called after all I/O operations with the storage are finished.

Parameters:
fsDouble pointer to the released file storage

The function starts writing a compound structure (collection) that can be a sequence or a map. After all the structure fields, which can be scalars or structures, are written, cvEndWriteStruct should be called. The function can be used to group some objects or to implement the write function for a some user object (see CvTypeInfo).

Parameters:
fsFile storage
nameName of the written structure. The structure can be accessed by this name when the storage is read.
struct_flagsA combination one of the following values:

  • **CV_NODE_SEQ** the written structure is a sequence (see discussion of CvFileStorage ), that is, its elements do not have a name.
  • **CV_NODE_MAP** the written structure is a map (see discussion of CvFileStorage ), that is, all its elements have names. One and only one of the two above flags must be specified
  • **CV_NODE_FLOW** the optional flag that makes sense only for YAML streams. It means that the structure is written as a flow (not as a block), which is more compact. It is recommended to use this flag for structures or arrays whose elements are all scalars.
type_nameOptional parameter - the object type name. In case of XML it is written as a type_id attribute of the structure opening tag. In the case of YAML it is written after a colon following the structure name (see the example in CvFileStorage description). Mainly it is used with user objects. When the storage is read, the encoded type name is used to determine the object type (see CvTypeInfo and cvFindType ).
attributesThis parameter is not used in the current implementation
fsFile storage
See also:
cvStartWriteStruct.

The function writes a single integer value (with or without a name) to the file storage.

Parameters:
fsFile storage
nameName of the written value. Should be NULL if and only if the parent structure is a sequence.
valueThe written value

The function writes a single floating-point value (with or without a name) to file storage. Special values are encoded as follows: NaN (Not A Number) as .NaN, infinity as +.Inf or -.Inf.

The following example shows how to use the low-level writing functions to store custom structures, such as termination criteria, without registering a new type. :

    void write_termcriteria( CvFileStorage* fs, const char* struct_name,
                             CvTermCriteria * termcrit )
    {
        cvStartWriteStruct( fs, struct_name, CV_NODE_MAP, NULL, cvAttrList(0,0));
        cvWriteComment( fs, "termination criteria", 1 ); // just a description
        if( termcrit->type & CV_TERMCRIT_ITER )
            cvWriteInteger( fs, "max_iterations", termcrit->max_iter );
        if( termcrit->type & CV_TERMCRIT_EPS )
            cvWriteReal( fs, "accuracy", termcrit->epsilon );
        cvEndWriteStruct( fs );
    }
Parameters:
fsFile storage
nameName of the written value. Should be NULL if and only if the parent structure is a sequence.
valueThe written value

The function writes a text string to file storage.

Parameters:
fsFile storage
nameName of the written string . Should be NULL if and only if the parent structure is a sequence.
strThe written text string
quoteIf non-zero, the written string is put in quotes, regardless of whether they are required. Otherwise, if the flag is zero, quotes are used only when they are required (e.g. when the string starts with a digit or contains spaces).

The function writes a comment into file storage. The comments are skipped when the storage is read.

Parameters:
fsFile storage
commentThe written comment, single-line or multi-line
eol_commentIf non-zero, the function tries to put the comment at the end of current line. If the flag is zero, if the comment is multi-line, or if it does not fit at the end of the current line, the comment starts a new line.

The function writes an object to file storage. First, the appropriate type info is found using cvTypeOf. Then, the write method associated with the type info is called.

Attributes are used to customize the writing procedure. The standard types support the following attributes (all the dt attributes have the same format as in cvWriteRawData):

  1. CvSeq
    • **header_dt** description of user fields of the sequence header that follow CvSeq, or CvChain (if the sequence is a Freeman chain) or CvContour (if the sequence is a contour or point sequence)
    • **dt** description of the sequence elements.
    • **recursive** if the attribute is present and is not equal to "0" or "false", the whole tree of sequences (contours) is stored.
  2. CvGraph
    • **header_dt** description of user fields of the graph header that follows CvGraph;
    • **vertex_dt** description of user fields of graph vertices
    • **edge_dt** description of user fields of graph edges (note that the edge weight is always written, so there is no need to specify it explicitly)

Below is the code that creates the YAML file shown in the CvFileStorage description:

    #include "cxcore.h"

    int main( int argc, char** argv )
    {
        CvMat* mat = cvCreateMat( 3, 3, CV_32F );
        CvFileStorage* fs = cvOpenFileStorage( "example.yml", 0, CV_STORAGE_WRITE );

        cvSetIdentity( mat );
        cvWrite( fs, "A", mat, cvAttrList(0,0) );

        cvReleaseFileStorage( &fs );
        cvReleaseMat( &mat );
        return 0;
    }
Parameters:
fsFile storage
nameName of the written object. Should be NULL if and only if the parent structure is a sequence.
ptrPointer to the object
attributesThe attributes of the object. They are specific for each particular type (see the discussion below).

The function finishes the currently written stream and starts the next stream. In the case of XML the file with multiple streams looks like this:

 {.xml}
    <opencv_storage>
    <!-- stream #1 data -->
    </opencv_storage>
    <opencv_storage>
    <!-- stream #2 data -->
    </opencv_storage>
    ...

The YAML file will look like this:

 {.yaml}
    %YAML:1.0
    # stream #1 data
    ...
    ---
    # stream #2 data

This is useful for concatenating files or for resuming the writing process.

Parameters:
fsFile storage

The function writes an array, whose elements consist of single or multiple numbers. The function call can be replaced with a loop containing a few cvWriteInt and cvWriteReal calls, but a single call is more efficient. Note that because none of the elements have a name, they should be written to a sequence rather than a map.

Parameters:
fsFile storage
srcPointer to the written array
lenNumber of the array elements to write
dtSpecification of each array element, see format specification

The function initializes the sequence reader to read data from a file node. The initialized reader can be then passed to cvReadRawDataSlice.

Parameters:
fsFile storage
srcThe file node (a sequence) to read numbers from
readerPointer to the sequence reader

The function reads one or more elements from the file node, representing a sequence, to a user-specified array. The total number of read sequence elements is a product of total and the number of components in each array element. For example, if dt=2if, the function will read total\*3 sequence elements. As with any sequence, some parts of the file node sequence can be skipped or read repeatedly by repositioning the reader using cvSetSeqReaderPos.

Parameters:
fsFile storage
readerThe sequence reader. Initialize it with cvStartReadRawData .
countThe number of elements to read
dstPointer to the destination array
dtSpecification of each array element. It has the same format as in cvWriteRawData .

The function reads elements from a file node that represents a sequence of scalars.

Parameters:
fsFile storage
srcThe file node (a sequence) to read numbers from
dstPointer to the destination array
dtSpecification of each array element. It has the same format as in cvWriteRawData .

The function writes a copy of a file node to file storage. Possible applications of the function are merging several file storages into one and conversion between XML and YAML formats.

Parameters:
fsDestination file storage
new_node_nameNew name of the file node in the destination file storage. To keep the existing name, use cvcvGetFileNodeName
nodeThe written node
embedIf the written node is a collection and this parameter is not zero, no extra level of hierarchy is created. Instead, all the elements of node are written into the currently written structure. Of course, map elements can only be embedded into another map, and sequence elements can only be embedded into another sequence.

The function registers a new type, which is described by info . The function creates a copy of the structure, so the user should delete it after calling the function.

Parameters:
infoType info structure

The function unregisters a type with a specified name. If the name is unknown, it is possible to locate the type info by an instance of the type using cvTypeOf or by iterating the type list, starting from cvFirstType, and then calling cvUnregisterType(info->typeName).

Parameters:
type_nameName of an unregistered type

The function finds the type of a given object and calls release with the double pointer.

Parameters:
struct_ptrDouble pointer to the object

The function saves an object to a file. It provides a simple interface to cvWrite .

Parameters:
filenameFile name
struct_ptrObject to save
nameOptional object name. If it is NULL, the name will be formed from filename .
commentOptional comment to put in the beginning of the file
attributesOptional attributes passed to cvWrite