opencv on mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

C API

Data Structures

struct  CvFont
 Font structure. More...
struct  CvConnectedComp
 Connected component structure. More...
struct  CvMoments
 Spatial and central moments. More...
struct  CvHuMoments
 Hu invariants. More...
struct  CvChainPtReader
 Freeman chain reader state. More...
struct  CvConvexityDefect
 Convexity defect. More...

Typedefs

typedef struct CvFont CvFont
 Font structure.
typedef struct CvConnectedComp CvConnectedComp
 Connected component structure.
typedef struct CvMoments CvMoments
 Spatial and central moments.
typedef struct CvHuMoments CvHuMoments
 Hu invariants.
typedef struct CvChainPtReader CvChainPtReader
 Freeman chain reader state.
typedef struct CvConvexityDefect CvConvexityDefect
 Convexity defect.

Enumerations

enum  SmoothMethod_c {
  CV_BLUR_NO_SCALE = 0, CV_BLUR = 1, CV_GAUSSIAN = 2, CV_MEDIAN = 3,
  CV_BILATERAL = 4
}
 

Image smooth methods.

More...
enum  
 

Filters used in pyramid decomposition.

More...
enum  
 

Special filters.

More...
enum  
 

Constants for color conversion.

More...
enum  
 

Sub-pixel interpolation methods.

More...
enum  
 

...

More...
enum  MorphShapes_c { , CV_SHAPE_CUSTOM = 100 }
 

Shapes of a structuring element for morphological operations.

More...
enum  
 

Morphological operations.

More...
enum  
 

Template matching methods.

More...
enum  
 

Contour retrieval modes.

More...
enum  
 

Contour approximation methods.

More...
enum  
 

Contour approximation algorithms.

More...
enum  ShapeMatchModes { CV_CONTOURS_MATCH_I1 = 1, CV_CONTOURS_MATCH_I2 = 2, CV_CONTOURS_MATCH_I3 = 3 }
 

Shape matching methods.

More...
enum  
 

Shape orientation.

More...
enum  
 

Histogram comparison methods.

More...
enum  
 

Mask size for distance transform.

More...
enum  
 

Content of output label array: connected components or pixels.

More...
enum  {
  CV_DIST_USER = -1, CV_DIST_L1 = 1, CV_DIST_L2 = 2, CV_DIST_C = 3,
  CV_DIST_L12 = 4, CV_DIST_FAIR = 5, CV_DIST_WELSCH = 6, CV_DIST_HUBER = 7
}
 

Distance types for Distance Transform and M-estimators.

More...
enum  {
  CV_THRESH_BINARY = 0, CV_THRESH_BINARY_INV = 1, CV_THRESH_TRUNC = 2, CV_THRESH_TOZERO = 3,
  CV_THRESH_TOZERO_INV = 4 , CV_THRESH_OTSU = 8, CV_THRESH_TRIANGLE = 16
}
 

Threshold types.

More...
enum  
 

Adaptive threshold methods.

More...
enum  
 

FloodFill flags.

More...
enum  
 

Canny edge detector flags.

More...
enum  
 

Variants of a Hough transform.

More...

Functions

 CVAPI (void) cvAcc(const CvArr *image
 Adds image to accumulator.
 CVAPI (CvMat **) cvCreatePyramid(const CvArr *img
 Builds pyramid for an image.
 CVAPI (CvMat *) cvGetAffineTransform(const CvPoint2D32f *src
 Computes affine transform matrix for mapping src[i] to dst[i] (i=0,1,2)
 CVAPI (IplConvKernel *) cvCreateStructuringElementEx(int cols
 Returns a structuring element of the specified size and shape for morphological operations.
 CVAPI (double) cvGetSpatialMoment(CvMoments *moments
 Retrieve spatial moments.
 CVAPI (int) cvSampleLine(const CvArr *image
 Fetches pixels that belong to the specified line segment and stores them to the buffer.
 CVAPI (float) cvCalcEMD2(const CvArr *signature1
 Computes earth mover distance between two weighted point sets (called signatures)
 CVAPI (CvContourScanner) cvStartFindContours(CvArr *image
 Initializes contour retrieving process.
 CVAPI (CvSeq *) cvFindNextContour(CvContourScanner scanner)
 Retrieves next contour.
 CVAPI (CvPoint) cvReadChainPoint(CvChainPtReader *reader)
 Retrieves the next chain point.
CV_INLINE double cvContourPerimeter (const void *contour)
 same as cvArcLength for closed contour
 CVAPI (CvRect) cvBoundingRect(CvArr *points
 Calculates contour bounding rectangle (update=1) or just retrieves pre-calculated rectangle (update=0)
 CVAPI (CvBox2D) cvMinAreaRect2(const CvArr *points
 Finds minimum area rotated rectangle bounding a set of points.
 CVAPI (CvHistogram *) cvCreateHist(int dims
 Creates a histogram.
CV_INLINE void cvCalcHist (IplImage **image, CvHistogram *hist, int accumulate CV_DEFAULT(0), const CvArr *mask CV_DEFAULT(NULL))
 CVAPI (CvScalar) cvColorToScalar(double packed_color
 Unpacks color value.
 CVAPI (void) cvPOSIT(CvPOSITObject *posit_object
 Deallocates an image header.
 CVAPI (double) cvCalibrateCamera2(const CvMat *object_points
 Calculates the dot product of two arrays in Euclidean metrics.

Typedef Documentation

Freeman chain reader state.

Connected component structure.

Convexity defect.

typedef struct CvFont CvFont

Font structure.

typedef struct CvHuMoments CvHuMoments

Hu invariants.

typedef struct CvMoments CvMoments

Spatial and central moments.


Enumeration Type Documentation

anonymous enum

Filters used in pyramid decomposition.

Definition at line 88 of file imgproc/types_c.h.

anonymous enum

Special filters.

Definition at line 94 of file imgproc/types_c.h.

anonymous enum

Constants for color conversion.

Definition at line 101 of file imgproc/types_c.h.

anonymous enum

Sub-pixel interpolation methods.

Definition at line 357 of file imgproc/types_c.h.

anonymous enum

...

and other image warping flags

Definition at line 367 of file imgproc/types_c.h.

anonymous enum

Morphological operations.

Definition at line 385 of file imgproc/types_c.h.

anonymous enum

Template matching methods.

Definition at line 431 of file imgproc/types_c.h.

anonymous enum

Contour retrieval modes.

Definition at line 444 of file imgproc/types_c.h.

anonymous enum

Contour approximation methods.

Definition at line 454 of file imgproc/types_c.h.

anonymous enum

Contour approximation algorithms.

Definition at line 489 of file imgproc/types_c.h.

anonymous enum

Shape orientation.

Definition at line 510 of file imgproc/types_c.h.

anonymous enum

Histogram comparison methods.

Definition at line 528 of file imgproc/types_c.h.

anonymous enum

Mask size for distance transform.

Definition at line 540 of file imgproc/types_c.h.

anonymous enum

Content of output label array: connected components or pixels.

Definition at line 548 of file imgproc/types_c.h.

anonymous enum

Distance types for Distance Transform and M-estimators.

Enumerator:
CV_DIST_USER 

User defined distance.

CV_DIST_L1 

distance = |x1-x2| + |y1-y2|

CV_DIST_L2 

the simple euclidean distance

CV_DIST_C 

distance = max(|x1-x2|,|y1-y2|)

CV_DIST_L12 

L1-L2 metric: distance = 2(sqrt(1+x*x/2) - 1))

CV_DIST_FAIR 

distance = c^2(|x|/c-log(1+|x|/c)), c = 1.3998

CV_DIST_WELSCH 

distance = c^2/2(1-exp(-(x/c)^2)), c = 2.9846

CV_DIST_HUBER 

distance = |x|<c ? x^2/2 : c(|x|-c/2), c=1.345

Definition at line 555 of file imgproc/types_c.h.

anonymous enum

Threshold types.

Enumerator:
CV_THRESH_BINARY 

value = value > threshold ? max_value : 0

CV_THRESH_BINARY_INV 

value = value > threshold ? 0 : max_value

CV_THRESH_TRUNC 

value = value > threshold ? threshold : value

CV_THRESH_TOZERO 

value = value > threshold ? value : 0

CV_THRESH_TOZERO_INV 

value = value > threshold ? 0 : value

CV_THRESH_OTSU 

use Otsu algorithm to choose the optimal threshold value; combine the flag with one of the above CV_THRESH_* values

CV_THRESH_TRIANGLE 

use Triangle algorithm to choose the optimal threshold value; combine the flag with one of the above CV_THRESH_* values, but not with CV_THRESH_OTSU

Definition at line 569 of file imgproc/types_c.h.

anonymous enum

Adaptive threshold methods.

Definition at line 585 of file imgproc/types_c.h.

anonymous enum

FloodFill flags.

Definition at line 592 of file imgproc/types_c.h.

anonymous enum

Canny edge detector flags.

Definition at line 600 of file imgproc/types_c.h.

anonymous enum

Variants of a Hough transform.

Definition at line 606 of file imgproc/types_c.h.

Shapes of a structuring element for morphological operations.

See also:
cv::MorphShapes, cv::getStructuringElement
Enumerator:
CV_SHAPE_CUSTOM 

custom structuring element

Definition at line 376 of file imgproc/types_c.h.

Shape matching methods.

$A$ denotes object1, $B$ denotes object2

$\begin{array}{l} m^A_i = \mathrm{sign} (h^A_i) \cdot \log{h^A_i} \\ m^B_i = \mathrm{sign} (h^B_i) \cdot \log{h^B_i} \end{array}$

and $h^A_i, h^B_i$ are the Hu moments of $A$ and $B$ , respectively.

Enumerator:
CV_CONTOURS_MATCH_I1 

\[I_1(A,B) = \sum _{i=1...7} \left | \frac{1}{m^A_i} - \frac{1}{m^B_i} \right |\]

CV_CONTOURS_MATCH_I2 

\[I_2(A,B) = \sum _{i=1...7} \left | m^A_i - m^B_i \right |\]

CV_CONTOURS_MATCH_I3 

\[I_3(A,B) = \max _{i=1...7} \frac{ \left| m^A_i - m^B_i \right| }{ \left| m^A_i \right| }\]

Definition at line 502 of file imgproc/types_c.h.

Image smooth methods.

Enumerator:
CV_BLUR_NO_SCALE 

linear convolution with $\texttt{size1}\times\texttt{size2}$ box kernel (all 1's).

If you want to smooth different pixels with different-size box kernels, you can use the integral image that is computed using integral

CV_BLUR 

linear convolution with $\texttt{size1}\times\texttt{size2}$ box kernel (all 1's) with subsequent scaling by $1/(\texttt{size1}\cdot\texttt{size2})$

CV_GAUSSIAN 

linear convolution with a $\texttt{size1}\times\texttt{size2}$ Gaussian kernel

CV_MEDIAN 

median filter with a $\texttt{size1}\times\texttt{size1}$ square aperture

CV_BILATERAL 

bilateral filter with a $\texttt{size1}\times\texttt{size1}$ square aperture, color sigma= sigma1 and spatial sigma= sigma2.

If size1=0, the aperture square side is set to cvRound(sigma2\*1.5)\*2+1. See cv::bilateralFilter

Definition at line 68 of file imgproc/types_c.h.


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
CVAPI ( void   ) const

Adds image to accumulator.

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.

See also:
cv::accumulate
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
CVAPI ( float   ) const

Computes earth mover distance between two weighted point sets (called signatures)

See also:
cv::EMD
CVAPI ( CvScalar   )

Unpacks color value.

if arrtype is CV_8UC?, _color_ is treated as packed color value, otherwise the first channels (depending on arrtype) of destination scalar are set to the same value = _color_

CVAPI ( double   )

Retrieve spatial moments.

Applies fixed-level threshold to grayscale image.

Compares two histogram.

Checks whether the point is inside polygon, outside, on an edge (at a vertex).

Compares two contours by matching their moments.

Calculates area of a contour or contour segment.

Calculates perimeter of a contour or length of a part of contour.

Retrieve normalized central moments.

Retrieve central moments.

See also:
cv::arcLength
cv::contourArea
cv::matchShapes

Returns positive, negative or zero value, correspondingly. Optionally, measures a signed distance between the point and the nearest polygon edge (measure_dist=1)

See also:
cv::pointPolygonTest

This is a basic operation applied before retrieving contours

See also:
cv::threshold
CVAPI ( double   ) const

Calculates the dot product of two arrays in Euclidean metrics.

Applies fixed-level threshold to grayscale image.

Compares two histogram.

Checks whether the point is inside polygon, outside, on an edge (at a vertex).

Compares two contours by matching their moments.

Calculates area of a contour or contour segment.

Calculates perimeter of a contour or length of a part of contour.

Retrieve normalized central moments.

Retrieve central moments.

Finds norm, difference norm or relative difference norm for an array (or two arrays)

Calculates Mahalanobis(weighted) distance.

Calculates determinant of input matrix.

Inverts matrix.

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. Must have a single channel.
idxArray of the element indices

The function calculates and returns the Euclidean dot product of two arrays.

\[src1 \bullet src2 = \sum _I ( \texttt{src1} (I) \texttt{src2} (I))\]

In the case of multiple channel arrays, the results for all channels are accumulated. In particular, cvDotProduct(a,a) where a is a complex vector, will return $||\texttt{a}||^2$. The function can process multi-dimensional arrays, row by row, layer by layer, and so on.

Parameters:
src1The first source array
src2The second source array
See also:
ref core_c_NormFlags "flags"
cv::arcLength
cv::contourArea
cv::matchShapes

Returns positive, negative or zero value, correspondingly. Optionally, measures a signed distance between the point and the nearest polygon edge (measure_dist=1)

See also:
cv::pointPolygonTest

This is a basic operation applied before retrieving contours

See also:
cv::threshold
CVAPI ( IplConvKernel *   )

Returns a structuring element of the specified size and shape for morphological operations.

Note:
the created structuring element IplConvKernel\* element must be released in the end using `cvReleaseStructuringElement(&element)`.
Parameters:
colsWidth of the structuring element
rowsHeight of the structuring element
anchor_xx-coordinate of the anchor
anchor_yy-coordinate of the anchor
shapeelement shape that could be one of the cv::MorphShapes_c
valuesinteger array of cols*rows elements that specifies the custom shape of the structuring element, when shape=CV_SHAPE_CUSTOM.
See also:
cv::getStructuringElement
CVAPI ( CvMat **   ) const

Builds pyramid for an image.

See also:
buildPyramid
CVAPI ( CvPoint   )

Retrieves the next chain point.

See also:
cvApproxChains
CVAPI ( CvMat  ) const

Computes affine transform matrix for mapping src[i] to dst[i] (i=0,1,2)

Computes perspective transform matrix for mapping src[i] to dst[i] (i=0,1,2,3)

Computes rotation_matrix matrix.

See also:
cv::getAffineTransform
cv::getRotationMatrix2D
cv::getPerspectiveTransform
CVAPI ( CvBox2D   ) const

Finds minimum area rotated rectangle bounding a set of points.

Fits ellipse into a set of 2d points.

See also:
cv::minAreaRect
cv::fitEllipse
CVAPI ( CvRect   )

Calculates contour bounding rectangle (update=1) or just retrieves pre-calculated rectangle (update=0)

Finds minimum rectangle containing two given rectangles.

See also:
cv::boundingRect
CVAPI ( int   ) const

Fetches pixels that belong to the specified line segment and stores them to the buffer.

Returns the polygon points which make up the given ellipse.

Initializes line iterator.

Clips the line segment connecting *pt1 and *pt2 by the rectangular window.

Checks whether the contour is convex or not (returns 1 if convex, 0 if not)

Finds minimum enclosing circle for a set of points.

Retrieves outer and optionally inner boundaries of white (non-zero) connected components in the black (zero) background.

Returns the number of retrieved points.

See also:
cv::LineSegmentDetector
cv::findContours, cvStartFindContours, cvFindNextContour, cvSubstituteContour, cvEndFindContours
cv::minEnclosingCircle
cv::isContourConvex

(0<=x<img_size.width, 0<=y<img_size.height).

See also:
cv::clipLine

Initially, line_iterator->ptr will point to pt1 (or pt2, see left_to_right description) location in the image. Returns the number of pixels on the line between the ending points.

See also:
cv::LineIterator

The ellipse is define by the box of size 'axes' rotated 'angle' around the 'center'. A partial sweep of the ellipse arc can be done by spcifying arc_start and arc_end to be something other than 0 and 360, respectively. The input array 'pts' must be large enough to hold the result. The total number of points stored into 'pts' is returned by this function.

See also:
cv::ellipse2Poly
CVAPI ( CvHistogram *   )

Creates a histogram.

Makes a histogram out of an array.

The function creates a histogram of the specified size and returns a pointer to the created histogram. If the array ranges is 0, the histogram bin ranges must be specified later via the function cvSetHistBinRanges. Though cvCalcHist and cvCalcBackProject may process 8-bit images without setting bin ranges, they assume they are equally spaced in 0 to 255 bins.

Parameters:
dimsNumber of histogram dimensions.
sizesArray of the histogram dimension sizes.
typeHistogram representation format. CV_HIST_ARRAY means that the histogram data is represented as a multi-dimensional dense array CvMatND. CV_HIST_SPARSE means that histogram data is represented as a multi-dimensional sparse array CvSparseMat.
rangesArray of ranges for the histogram bins. Its meaning depends on the uniform parameter value. The ranges are used when the histogram is calculated or backprojected to determine which histogram bin corresponds to which value/tuple of values from the input image(s).
uniformUniformity flag. If not zero, the histogram has evenly spaced bins and for every $0<=i<cDims$ ranges[i] is an array of two numbers: lower and upper boundaries for the i-th histogram dimension. The whole range [lower,upper] is then split into dims[i] equal parts to determine the i-th input tuple value ranges for every histogram bin. And if uniform=0 , then the i-th element of the ranges array contains dims[i]+1 elements: $\texttt{lower}_0, \texttt{upper}_0, \texttt{lower}_1, \texttt{upper}_1 = \texttt{lower}_2, ... \texttt{upper}_{dims[i]-1}$ where $\texttt{lower}_j$ and $\texttt{upper}_j$ are lower and upper boundaries of the i-th input tuple value for the j-th bin, respectively. In either case, the input values that are beyond the specified range for a histogram bin are not counted by cvCalcHist and filled with 0 by cvCalcBackProject.

The function initializes the histogram, whose header and bins are allocated by the user. cvReleaseHist does not need to be called afterwards. Only dense histograms can be initialized this way. The function returns hist.

Parameters:
dimsNumber of the histogram dimensions.
sizesArray of the histogram dimension sizes.
histHistogram header initialized by the function.
dataArray used to store histogram bins.
rangesHistogram bin ranges. See cvCreateHist for details.
uniformUniformity flag. See cvCreateHist for details.
CVAPI ( CvContourScanner   )

Initializes contour retrieving process.

Calls cvStartFindContours. Calls cvFindNextContour until null pointer is returned or some other condition becomes true. Calls cvEndFindContours at the end.

See also:
cvFindContours
CVAPI ( CvSeq *   )

Retrieves next contour.

Finds circles in the image.

Finds lines on binary image using one of several methods.

Initializes sequence header for a matrix (column or row vector) of points.

Finds convexity defects for the contour.

Calculates exact convex hull of 2d point set.

Approximates a single polygonal curve (contour) or a tree of polygonal curves (contours)

Approximates Freeman chain(s) with a polygonal curve.

Releases contour scanner and returns pointer to the first outer contour.

See also:
cvFindContours

This is a standalone contour approximation routine, not represented in the new interface. When cvFindContours retrieves contours as Freeman chains, it calls the function to get approximated contours, represented as polygons.

Parameters:
src_seqPointer to the approximated Freeman chain that can refer to other chains.
storageStorage location for the resulting polylines.
methodApproximation method (see the description of the function :ocvFindContours ).
parameterMethod parameter (not used now).
minimal_perimeterApproximates only those contours whose perimeters are not less than minimal_perimeter . Other chains are removed from the resulting structure.
recursiveRecursion flag. If it is non-zero, the function approximates all chains that can be obtained from chain by using the h_next or v_next links. Otherwise, the single input chain is approximated.
See also:
cvStartReadChainPoints, cvReadChainPoint
cv::approxPolyDP
cv::convexHull
cv::convexityDefects

a wrapper for cvMakeSeqHeaderForArray (it does not initialize bounding rectangle!!!)

line_storage is either memory storage or 1 x _max number of lines_ CvMat, its number of columns is changed by the function. method is one of CV_HOUGH_*; rho, theta and threshold are used for each of those methods; param1 ~ line length, param2 ~ line gap - for probabilistic, param1 ~ srn, param2 ~ stn - for multi-scale

See also:
cv::HoughLines
cv::HoughCircles
CV_INLINE void cvCalcHist ( IplImage **  image,
CvHistogram *  hist,
int accumulate   CV_DEFAULT0,
const CvArr *mask   CV_DEFAULTNULL 
)

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

Definition at line 771 of file imgproc_c.h.

CV_INLINE double cvContourPerimeter ( const void *  contour )

same as cvArcLength for closed contour

Definition at line 530 of file imgproc_c.h.