📄 cxcore.h
字号:
#define CV_FRONT 1
#define CV_BACK 0
/* Adds several new elements to the end of sequence */
CVAPI(void) cvSeqPushMulti( CvSeq* seq, void* elements,
int count, int in_front CV_DEFAULT(0) );
/* Removes several elements from the end of sequence and optionally saves them */
CVAPI(void) cvSeqPopMulti( CvSeq* seq, void* elements,
int count, int in_front CV_DEFAULT(0) );
/* Inserts a new element in the middle of sequence.
cvSeqInsert(seq,0,elem) == cvSeqPushFront(seq,elem) */
CVAPI(char*) cvSeqInsert( CvSeq* seq, int before_index,
void* element CV_DEFAULT(NULL));
/* Removes specified sequence element */
CVAPI(void) cvSeqRemove( CvSeq* seq, int index );
/* Removes all the elements from the sequence. The freed memory
can be reused later only by the same sequence unless cvClearMemStorage
or cvRestoreMemStoragePos is called */
CVAPI(void) cvClearSeq( CvSeq* seq );
/* Retrives pointer to specified sequence element.
Negative indices are supported and mean counting from the end
(e.g -1 means the last sequence element) */
CVAPI(char*) cvGetSeqElem( const CvSeq* seq, int index );
/* Calculates index of the specified sequence element.
Returns -1 if element does not belong to the sequence */
CVAPI(int) cvSeqElemIdx( const CvSeq* seq, const void* element,
CvSeqBlock** block CV_DEFAULT(NULL) );
/* Initializes sequence writer. The new elements will be added to the end of sequence */
CVAPI(void) cvStartAppendToSeq( CvSeq* seq, CvSeqWriter* writer );
/* Combination of cvCreateSeq and cvStartAppendToSeq */
CVAPI(void) cvStartWriteSeq( int seq_flags, int header_size,
int elem_size, CvMemStorage* storage,
CvSeqWriter* writer );
/* Closes sequence writer, updates sequence header and returns pointer
to the resultant sequence
(which may be useful if the sequence was created using cvStartWriteSeq))
*/
CVAPI(CvSeq*) cvEndWriteSeq( CvSeqWriter* writer );
/* Updates sequence header. May be useful to get access to some of previously
written elements via cvGetSeqElem or sequence reader */
CVAPI(void) cvFlushSeqWriter( CvSeqWriter* writer );
/* Initializes sequence reader.
The sequence can be read in forward or backward direction */
CVAPI(void) cvStartReadSeq( const CvSeq* seq, CvSeqReader* reader,
int reverse CV_DEFAULT(0) );
/* Returns current sequence reader position (currently observed sequence element) */
CVAPI(int) cvGetSeqReaderPos( CvSeqReader* reader );
/* Changes sequence reader position. It may seek to an absolute or
to relative to the current position */
CVAPI(void) cvSetSeqReaderPos( CvSeqReader* reader, int index,
int is_relative CV_DEFAULT(0));
/* Copies sequence content to a continuous piece of memory */
CVAPI(void*) cvCvtSeqToArray( const CvSeq* seq, void* elements,
CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ) );
/* Creates sequence header for array.
After that all the operations on sequences that do not alter the content
can be applied to the resultant sequence */
CVAPI(CvSeq*) cvMakeSeqHeaderForArray( int seq_type, int header_size,
int elem_size, void* elements, int total,
CvSeq* seq, CvSeqBlock* block );
/* Extracts sequence slice (with or without copying sequence elements) */
CVAPI(CvSeq*) cvSeqSlice( const CvSeq* seq, CvSlice slice,
CvMemStorage* storage CV_DEFAULT(NULL),
int copy_data CV_DEFAULT(0));
CV_INLINE CvSeq* cvCloneSeq( const CvSeq* seq, CvMemStorage* storage CV_DEFAULT(NULL));
CV_INLINE CvSeq* cvCloneSeq( const CvSeq* seq, CvMemStorage* storage )
{
return cvSeqSlice( seq, CV_WHOLE_SEQ, storage, 1 );
}
/* Removes sequence slice */
CVAPI(void) cvSeqRemoveSlice( CvSeq* seq, CvSlice slice );
/* Inserts a sequence or array into another sequence */
CVAPI(void) cvSeqInsertSlice( CvSeq* seq, int before_index, const CvArr* from_arr );
/* a < b ? -1 : a > b ? 1 : 0 */
typedef int (CV_CDECL* CvCmpFunc)(const void* a, const void* b, void* userdata );
/* Sorts sequence in-place given element comparison function */
CVAPI(void) cvSeqSort( CvSeq* seq, CvCmpFunc func, void* userdata CV_DEFAULT(NULL) );
/* Finds element in a [sorted] sequence */
CVAPI(char*) cvSeqSearch( CvSeq* seq, const void* elem, CvCmpFunc func,
int is_sorted, int* elem_idx,
void* userdata CV_DEFAULT(NULL) );
/* Reverses order of sequence elements in-place */
CVAPI(void) cvSeqInvert( CvSeq* seq );
/* Splits sequence into one or more equivalence classes using the specified criteria */
CVAPI(int) cvSeqPartition( const CvSeq* seq, CvMemStorage* storage,
CvSeq** labels, CvCmpFunc is_equal, void* userdata );
/************ Internal sequence functions ************/
CVAPI(void) cvChangeSeqBlock( CvSeqReader* reader, int direction );
CVAPI(void) cvCreateSeqBlock( CvSeqWriter* writer );
/* Creates a new set */
CVAPI(CvSet*) cvCreateSet( int set_flags, int header_size,
int elem_size, CvMemStorage* storage );
/* Adds new element to the set and returns pointer to it */
CVAPI(int) cvSetAdd( CvSet* set_header, CvSetElem* elem CV_DEFAULT(NULL),
CvSetElem** inserted_elem CV_DEFAULT(NULL) );
/* Fast variant of cvSetAdd */
CV_INLINE CvSetElem* cvSetNew( CvSet* set_header );
CV_INLINE CvSetElem* cvSetNew( CvSet* set_header )
{
CvSetElem* elem = set_header->free_elems;
if( elem )
{
set_header->free_elems = elem->next_free;
elem->flags = elem->flags & CV_SET_ELEM_IDX_MASK;
set_header->active_count++;
}
else
cvSetAdd( set_header, NULL, (CvSetElem**)&elem );
return elem;
}
/* Removes set element given its pointer */
CV_INLINE void cvSetRemoveByPtr( CvSet* set_header, void* elem );
CV_INLINE void cvSetRemoveByPtr( CvSet* set_header, void* elem )
{
CvSetElem* _elem = (CvSetElem*)elem;
assert( _elem->flags >= 0 /*&& (elem->flags & CV_SET_ELEM_IDX_MASK) < set_header->total*/ );
_elem->next_free = set_header->free_elems;
_elem->flags = (_elem->flags & CV_SET_ELEM_IDX_MASK) | CV_SET_ELEM_FREE_FLAG;
set_header->free_elems = _elem;
set_header->active_count--;
}
/* Removes element from the set by its index */
CVAPI(void) cvSetRemove( CvSet* set_header, int index );
/* Returns a set element by index. If the element doesn't belong to the set,
NULL is returned */
CV_INLINE CvSetElem* cvGetSetElem( const CvSet* set_header, int index );
CV_INLINE CvSetElem* cvGetSetElem( const CvSet* set_header, int index )
{
CvSetElem* elem = (CvSetElem*)cvGetSeqElem( (CvSeq*)set_header, index );
return elem && CV_IS_SET_ELEM( elem ) ? elem : 0;
}
/* Removes all the elements from the set */
CVAPI(void) cvClearSet( CvSet* set_header );
/* Creates new graph */
CVAPI(CvGraph*) cvCreateGraph( int graph_flags, int header_size,
int vtx_size, int edge_size,
CvMemStorage* storage );
/* Adds new vertex to the graph */
CVAPI(int) cvGraphAddVtx( CvGraph* graph, const CvGraphVtx* vtx CV_DEFAULT(NULL),
CvGraphVtx** inserted_vtx CV_DEFAULT(NULL) );
/* Removes vertex from the graph together with all incident edges */
CVAPI(int) cvGraphRemoveVtx( CvGraph* graph, int index );
CVAPI(int) cvGraphRemoveVtxByPtr( CvGraph* graph, CvGraphVtx* vtx );
/* Link two vertices specifed by indices or pointers if they
are not connected or return pointer to already existing edge
connecting the vertices.
Functions return 1 if a new edge was created, 0 otherwise */
CVAPI(int) cvGraphAddEdge( CvGraph* graph,
int start_idx, int end_idx,
const CvGraphEdge* edge CV_DEFAULT(NULL),
CvGraphEdge** inserted_edge CV_DEFAULT(NULL) );
CVAPI(int) cvGraphAddEdgeByPtr( CvGraph* graph,
CvGraphVtx* start_vtx, CvGraphVtx* end_vtx,
const CvGraphEdge* edge CV_DEFAULT(NULL),
CvGraphEdge** inserted_edge CV_DEFAULT(NULL) );
/* Remove edge connecting two vertices */
CVAPI(void) cvGraphRemoveEdge( CvGraph* graph, int start_idx, int end_idx );
CVAPI(void) cvGraphRemoveEdgeByPtr( CvGraph* graph, CvGraphVtx* start_vtx,
CvGraphVtx* end_vtx );
/* Find edge connecting two vertices */
CVAPI(CvGraphEdge*) cvFindGraphEdge( const CvGraph* graph, int start_idx, int end_idx );
CVAPI(CvGraphEdge*) cvFindGraphEdgeByPtr( const CvGraph* graph,
const CvGraphVtx* start_vtx,
const CvGraphVtx* end_vtx );
#define cvGraphFindEdge cvFindGraphEdge
#define cvGraphFindEdgeByPtr cvFindGraphEdgeByPtr
/* Remove all vertices and edges from the graph */
CVAPI(void) cvClearGraph( CvGraph* graph );
/* Count number of edges incident to the vertex */
CVAPI(int) cvGraphVtxDegree( const CvGraph* graph, int vtx_idx );
CVAPI(int) cvGraphVtxDegreeByPtr( const CvGraph* graph, const CvGraphVtx* vtx );
/* Retrieves graph vertex by given index */
#define cvGetGraphVtx( graph, idx ) (CvGraphVtx*)cvGetSetElem((CvSet*)(graph), (idx))
/* Retrieves index of a graph vertex given its pointer */
#define cvGraphVtxIdx( graph, vtx ) ((vtx)->flags & CV_SET_ELEM_IDX_MASK)
/* Retrieves index of a graph edge given its pointer */
#define cvGraphEdgeIdx( graph, edge ) ((edge)->flags & CV_SET_ELEM_IDX_MASK)
#define cvGraphGetVtxCount( graph ) ((graph)->active_count)
#define cvGraphGetEdgeCount( graph ) ((graph)->edges->active_count)
#define CV_GRAPH_VERTEX 1
#define CV_GRAPH_TREE_EDGE 2
#define CV_GRAPH_BACK_EDGE 4
#define CV_GRAPH_FORWARD_EDGE 8
#define CV_GRAPH_CROSS_EDGE 16
#define CV_GRAPH_ANY_EDGE 30
#define CV_GRAPH_NEW_TREE 32
#define CV_GRAPH_BACKTRACKING 64
#define CV_GRAPH_OVER -1
#define CV_GRAPH_ALL_ITEMS -1
/* flags for graph vertices and edges */
#define CV_GRAPH_ITEM_VISITED_FLAG (1 << 30)
#define CV_IS_GRAPH_VERTEX_VISITED(vtx) \
(((CvGraphVtx*)(vtx))->flags & CV_GRAPH_ITEM_VISITED_FLAG)
#define CV_IS_GRAPH_EDGE_VISITED(edge) \
(((CvGraphEdge*)(edge))->flags & CV_GRAPH_ITEM_VISITED_FLAG)
#define CV_GRAPH_SEARCH_TREE_NODE_FLAG (1 << 29)
#define CV_GRAPH_FORWARD_EDGE_FLAG (1 << 28)
typedef struct CvGraphScanner
{
CvGraphVtx* vtx; /* current graph vertex (or current edge origin) */
CvGraphVtx* dst; /* current graph edge destination vertex */
CvGraphEdge* edge; /* current edge */
CvGraph* graph; /* the graph */
CvSeq* stack; /* the graph vertex stack */
int index; /* the lower bound of certainly visited vertices */
int mask; /* event mask */
}
CvGraphScanner;
/* Creates new graph scanner. */
CVAPI(CvGraphScanner*) cvCreateGraphScanner( CvGraph* graph,
CvGraphVtx* vtx CV_DEFAULT(NULL),
int mask CV_DEFAULT(CV_GRAPH_ALL_ITEMS));
/* Releases graph scanner. */
CVAPI(void) cvReleaseGraphScanner( CvGraphScanner** scanner );
/* Get next graph element */
CVAPI(int) cvNextGraphItem( CvGraphScanner* scanner );
/* Creates a copy of graph */
CVAPI(CvGraph*) cvCloneGraph( const CvGraph* graph, CvMemStorage* storage );
/****************************************************************************************\
* Drawing *
\****************************************************************************************/
/****************************************************************************************\
* Drawing functions work with images/matrices of arbitrary type. *
* For color images the channel order is BGR[A] *
* Antialiasing is supported only for 8-bit image now. *
* All the functions include parameter color that means rgb value (that may be *
* constructed with CV_RGB macro) for color images and brightness *
* for grayscale images. *
* If a drawn figure is partially or completely outside the image, it is clipped. *
\****************************************************************************************/
#define CV_RGB( r, g, b ) cvScalar( (b), (g), (r), 0 )
#define CV_FILLED -1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -