#ifdef __cplusplus
# include "opencv2/core.hpp"
#endif
/* CvArr* is used to pass arbitrary
* array-like data structures
* into functions where the particular
* array type is recognized at runtime:
*/
typedef void CvArr;
typedef union Cv32suf
{
int i;
unsigned u;
float f;
}
Cv32suf;
enum {
CV_StsOk= 0, /* everithing is ok */
CV_StsBackTrace= -1, /* pseudo error for back trace */
CV_StsError= -2, /* unknown /unspecified error */
CV_StsInternal= -3, /* internal error (bad state) */
CV_StsNoMem= -4, /* insufficient memory */
CV_StsBadArg= -5, /* function arg/param is bad */
CV_StsBadFunc= -6, /* unsupported function */
CV_StsNoConv= -7, /* iter. didn‘t converge */
CV_StsAutoTrace= -8, /* tracing */
CV_HeaderIsNull= -9, /* image header is NULL */
CV_BadImageSize= -10, /* image size is invalid */
CV_BadOffset= -11, /* offset is invalid */
CV_BadDataPtr= -12, /**/
CV_BadStep= -13, /**/
CV_BadModelOrChSeq= -14, /**/
CV_BadNumChannels= -15, /**/
CV_BadNumChannel1U= -16, /**/
CV_BadDepth= -17, /**/
CV_BadAlphaChannel= -18, /**/
CV_BadOrder= -19, /**/
CV_BadOrigin= -20, /**/
CV_BadAlign= -21, /**/
CV_BadCallBack= -22, /**/
CV_BadTileSize= -23, /**/
CV_BadCOI= -24, /**/
CV_BadROISize= -25, /**/
CV_MaskIsTiled= -26, /**/
CV_StsNullPtr= -27, /* null pointer */
CV_StsVecLengthErr= -28, /* incorrect vector length */
CV_StsFilterStructContentErr= -29, /* incorr. filter structure content */
CV_StsKernelStructContentErr= -30, /* incorr. transform kernel content */
CV_StsFilterOffsetErr= -31, /* incorrect filter offset value */
CV_StsBadSize= -201, /* the input/output structure size is incorrect */
CV_StsDivByZero= -202, /* division by zero */
CV_StsInplaceNotSupported= -203, /* in-place operation is not supported */
CV_StsObjectNotFound= -204, /* request can‘t be completed */
CV_StsUnmatchedFormats= -205, /* formats of input/output arrays differ */
CV_StsBadFlag= -206, /* flag is wrong or not supported */
CV_StsBadPoint= -207, /* bad CvPoint */
CV_StsBadMask= -208, /* bad format of mask (neither 8uC1 nor 8sC1)*/
CV_StsUnmatchedSizes= -209, /* sizes of input/output structures do not match */
CV_StsUnsupportedFormat= -210, /* the data format/type is not supported by the function*/
CV_StsOutOfRange= -211, /* some of parameters are out of range */
CV_StsParseError= -212, /* invalid syntax/structure of the parsed file */
CV_StsNotImplemented= -213, /* the requested function/feature is not implemented */
CV_StsBadMemBlock= -214, /* an allocated block has been corrupted */
CV_StsAssert= -215, /* assertion failed */
CV_GpuNotSupported= -216,
CV_GpuApiCallError= -217,
CV_OpenGlNotSupported= -218,
CV_OpenGlApiCallError= -219,
CV_OpenCLApiCallError= -220,
CV_OpenCLDoubleNotSupported= -221,
CV_OpenCLInitError= -222,
CV_OpenCLNoAMDBlasFft= -223
};
/****************************************************************************************\
* Common macros and inline functions *
\****************************************************************************************/
/* Returns random floating-point number between 0 and 1: */
CV_INLINE double cvRandReal( CvRNG* rng )
{
return cvRandInt(rng)*2.3283064365386962890625e-10 /* 2^-32 */;
}
/****************************************************************************************\
* Image type (IplImage) *
\****************************************************************************************/
#ifndef HAVE_IPL
/*
* The following definitions (until #endif)
* is an extract from IPL headers.
* Copyright (c) 1995 Intel Corporation.
*/
#define IPL_DEPTH_SIGN 0x80000000
typedef struct
#ifdef __cplusplus
CV_EXPORTS
#endif
_IplImage
{
int nSize; /* sizeof(IplImage) */
int ID; /* version (=0)*/
int nChannels; /* Most of OpenCV functions support 1,2,3 or 4 channels */
int alphaChannel; /* Ignored by OpenCV */
int depth; /* Pixel depth in bits: IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16S,
IPL_DEPTH_32S, IPL_DEPTH_32F and IPL_DEPTH_64F are supported. */
char colorModel[4]; /* Ignored by OpenCV */
char channelSeq[4]; /* ditto */
int dataOrder; /* 0 - interleaved color channels, 1 - separate color channels.
cvCreateImage can only create interleaved images */
int origin; /* 0 - top-left origin,
1 - bottom-left origin (Windows bitmaps style). */
int align; /* Alignment of image rows (4 or 8).
OpenCV ignores it and uses widthStep instead. */
int width; /* Image width in pixels. */
int height; /* Image height in pixels. */
struct _IplROI *roi; /* Image ROI. If NULL, the whole image is selected. */
struct _IplImage *maskROI; /* Must be NULL. */
void *imageId; /* " " */
struct _IplTileInfo *tileInfo; /* " " */
int imageSize; /* Image data size in bytes
(==image->height*image->widthStep
in case of interleaved data)*/
char *imageData; /* Pointer to aligned image data. */
int widthStep; /* Size of aligned image row in bytes. */
int BorderMode[4]; /* Ignored by OpenCV. */
int BorderConst[4]; /* Ditto. */
char *imageDataOrigin; /* Pointer to very origin of image data
(not necessarily aligned) -
needed for correct deallocation */
typedef struct _IplROI
{
int coi; /* 0 - no COI (all channels are selected), 1 - 0th channel is selected ...*/
int xOffset;
int yOffset;
int width;
int height;
}
IplROI;
typedef struct _IplConvKernel
{
int nCols;
int nRows;
int anchorX;
int anchorY;
int *values;
int nShiftR;
}
IplConvKernel;
typedef struct _IplConvKernelFP
{
int nCols;
int nRows;
int anchorX;
int anchorY;
float *values;
}
IplConvKernelFP;
/* for storing double-precision
floating point data in IplImage‘s */
#define IPL_DEPTH_64F 64
/* get reference to pixel at (col,row),
for multi-channel images (col) should be multiplied by number of channels */
#define CV_IMAGE_ELEM( image, elemtype, row, col ) \
(((elemtype*)((image)->imageData + (image)->widthStep*(row)))[(col)])
/****************************************************************************************\
* Matrix type (CvMat) *
\****************************************************************************************/
/* Inline constructor. No data is allocated internally!!!
* (Use together with cvCreateData, or use cvCreateMat instead to
* get a matrix with allocated data):
*/
CV_INLINE CvMat cvMat( int rows, int cols, int type, void* data CV_DEFAULT(NULL))
{
CvMat m;
/****************************************************************************************\
* Other supplementary data type definitions *
\****************************************************************************************/
typedef struct CvBox2D
{
CvPoint2D32f center; /* Center of the box. */
CvSize2D32f size; /* Box width and length. */
float angle; /* Angle between the horizontal axis */
/* and the first side (i.e. length) in degrees */
typedef struct CvMemStorage
{
int signature;
CvMemBlock* bottom; /* First allocated block. */
CvMemBlock* top; /* Current memory block - top of the stack. */
struct CvMemStorage* parent; /* We get new blocks from parent as needed. */
int block_size; /* Block size. */
int free_space; /* Remaining free space in current block. */
}
CvMemStorage;
typedef struct CvSeqBlock
{
struct CvSeqBlock* prev; /* Previous sequence block. */
struct CvSeqBlock* next; /* Next sequence block. */
int start_index; /* Index of the first element in the block + */
/* sequence->first->start_index. */
int count; /* Number of elements in the block. */
schar* data; /* Pointer to the first element of the block. */
}
CvSeqBlock;
/*
Read/Write sequence.
Elements can be dynamically inserted to or deleted from the sequence.
*/
#define CV_SEQUENCE_FIELDS() \
CV_TREE_NODE_FIELDS(CvSeq); \
int total; /* Total number of elements. */ \
int elem_size; /* Size of sequence element in bytes. */ \
schar* block_max; /* Maximal bound of the last block. */ \
schar* ptr; /* Current write pointer. */ \
int delta_elems; /* Grow seq this many at a time. */ \
CvMemStorage* storage; /* Where the seq is stored. */ \
CvSeqBlock* free_blocks; /* Free blocks list. */ \
CvSeqBlock* first; /* Pointer to the first sequence block. */
/*************************************** Set ********************************************/
/*
Set.
Order is not preserved. There can be gaps between sequence elements.
After the element has been inserted it stays in the same place all the time.
The MSB(most-significant or sign bit) of the first field (flags) is 0 iff the element exists.
*/
#define CV_SET_ELEM_FIELDS(elem_type) \
int flags; \
struct elem_type* next_free;
/*
We represent a graph as a set of vertices.
Vertices contain their adjacency lists (more exactly, pointers to first incoming or
outcoming edge (or 0 if isolated vertex)). Edges are stored in another set.
There is a singly-linked list of incoming/outcoming edges for each vertex.
Each edge consists of
o Two pointers to the starting and ending vertices
(vtx[0] and vtx[1] respectively).
A graph may be oriented or not. In the latter case, edges between
vertex i to vertex j are not distinguished during search operations.
o Two pointers to next edges for the starting and ending vertices, where
next[0] points to the next edge in the vtx[0] adjacency list and
next[1] points to the next edge in the vtx[1] adjacency list.
*/
#define CV_GRAPH_EDGE_FIELDS() \
int flags; \
float weight; \
struct CvGraphEdge* next[2]; \
struct CvGraphVtx* vtx[2];
#define CV_GRAPH_VERTEX_FIELDS() \
int flags; \
struct CvGraphEdge* first;
/*
Graph is "derived" from the set (this is set a of vertices)
and includes another set (edges)
*/
#define CV_GRAPH_FIELDS() \
CV_SET_FIELDS() \
CvSet* edges;
#define CV_SEQ_WRITER_FIELDS() \
int header_size; \
CvSeq* seq; /* the sequence written */ \
CvSeqBlock* block; /* current block */ \
schar* ptr; /* pointer to free space */ \
schar* block_min; /* pointer to the beginning of block*/\
schar* block_max; /* pointer to the end of block */
#define CV_SEQ_READER_FIELDS() \
int header_size; \
CvSeq* seq; /* sequence, beign read */ \
CvSeqBlock* block; /* current block */ \
schar* ptr; /* pointer to element be read next */ \
schar* block_min; /* pointer to the beginning of block */\
schar* block_max; /* pointer to the end of block */ \
int delta_index;/* = seq->first->start_index */ \
schar* prev_elem; /* pointer to previous element */
/* List of attributes: */
typedef struct CvAttrList
{
const char** attr; /* NULL-terminated array of (attribute_name,attribute_value) pairs. */
struct CvAttrList* next; /* Pointer to next chunk of the attributes list. */
}
CvAttrList;
typedef struct CvString
{
int len;
char* ptr;
}
CvString;
/* All the keys (names) of elements in the readed file storage
are stored in the hash to speed up the lookup operations: */
typedef struct CvStringHashNode
{
unsigned hashval;
CvString str;
struct CvStringHashNode* next;
}
CvStringHashNode;
typedef struct CvGenericHash CvFileNodeHash;
/* Basic element of the file storage - scalar or collection: */
typedef struct CvFileNode
{
int tag;
struct CvTypeInfo* info; /* type information
(only for user-defined object, for others it is 0) */
union
{
double f; /* scalar floating-point number */
int i; /* scalar integer number */
CvString str; /* text string */
CvSeq* seq; /* sequence (ordered collection of file nodes) */
CvFileNodeHash* map; /* map (collection of named file nodes) */
} data;
}
CvFileNode;