📄 cv.h
字号:
OPENCVAPI void cvStartReadSeq( const CvSeq* seq, CvSeqReader* reader,
int reverse CV_DEFAULT(0) );
/* Returns current sequence reader position (currently observed sequence element) */
OPENCVAPI int cvGetSeqReaderPos( CvSeqReader* reader );
/* Changes sequence reader position. It may seek to an absolute or
to relative to the current position */
OPENCVAPI void cvSetSeqReaderPos( CvSeqReader* reader, int index,
int is_relative CV_DEFAULT(0));
/* Copies sequence content to an array */
OPENCVAPI void* cvCvtSeqToArray( CvSeq* seq, CvArr* array,
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 */
OPENCVAPI 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 */
OPENCVAPI CvSeq* cvSeqSlice( CvSeq* seq, CvSlice slice,
CvMemStorage* storage CV_DEFAULT(NULL),
int copy_data CV_DEFAULT(0));
CV_INLINE CvSeq* cvCloneSeq( CvSeq* seq, CvMemStorage* storage CV_DEFAULT(NULL));
CV_INLINE CvSeq* cvCloneSeq( CvSeq* seq, CvMemStorage* storage )
{
return cvSeqSlice( seq, CV_WHOLE_SEQ, storage, 1 );
}
/* Removes sequence slice */
OPENCVAPI void cvSeqRemoveSlice( CvSeq* seq, CvSlice slice );
/* Inserts a sequence or array into another sequence */
OPENCVAPI void cvSeqInsertSlice( CvSeq* seq, int index, const CvArr* from_arr );
/* a < b ? -1 : a > b ? 1 : 0 */
CV_EXTERN_C_FUNCPTR( int (CV_CDECL* CvCmpFunc)
(const void* a, const void* b, void* userdata ));
/* Sorts sequence in-place given element comparison function */
OPENCVAPI void cvSeqSort( CvSeq* seq, CvCmpFunc func, void* userdata );
/* Reverses order of sequence elements in-place */
OPENCVAPI void cvSeqInvert( CvSeq* seq );
/* Splits sequence into set of equivalency classes
using specified equivalency criteria */
OPENCVAPI int cvPartitionSeq( CvSeq* seq, CvMemStorage* storage, CvSeq** comps,
CvCmpFunc is_equal, void* userdata, int is_set );
/************ Internal sequence functions ************/
OPENCVAPI void cvChangeSeqBlock( CvSeqReader* reader, int direction );
OPENCVAPI void cvCreateSeqBlock( CvSeqWriter* writer );
/* Creates a new set */
OPENCVAPI CvSet* cvCreateSet( int set_flags, int header_size,
int elem_size, CvMemStorage* storage );
/* Adds new element to the set and returns pointer to it */
OPENCVAPI int cvSetAdd( CvSet* set_header, CvSetElem* element CV_DEFAULT(NULL),
CvSetElem** inserted_element 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;
}
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;
}
/* Removes element from the set by its index */
OPENCVAPI 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 */
OPENCVAPI CvSetElem* cvGetSetElem( CvSet* set_header, int index );
/* Removes all the elements from the set */
OPENCVAPI void cvClearSet( CvSet* set_header );
/* Creates new graph */
OPENCVAPI CvGraph* cvCreateGraph( int graph_flags, int header_size,
int vtx_size, int edge_size,
CvMemStorage* storage );
/* Adds new vertex to the graph */
OPENCVAPI int cvGraphAddVtx( CvGraph* graph, CvGraphVtx* vertex CV_DEFAULT(NULL),
CvGraphVtx** inserted_vertex CV_DEFAULT(NULL) );
/* Removes vertex from the graph together with all incident edges */
OPENCVAPI void cvGraphRemoveVtx( CvGraph* graph, int index );
OPENCVAPI void 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 */
OPENCVAPI int cvGraphAddEdge( CvGraph* graph,
int start_idx, int end_idx,
CvGraphEdge* edge CV_DEFAULT(NULL),
CvGraphEdge** inserted_edge CV_DEFAULT(NULL) );
OPENCVAPI int cvGraphAddEdgeByPtr( CvGraph* graph,
CvGraphVtx* start_vtx, CvGraphVtx* end_vtx,
CvGraphEdge* edge CV_DEFAULT(NULL),
CvGraphEdge** inserted_edge CV_DEFAULT(NULL) );
/* Remove edge connecting two vertices */
OPENCVAPI void cvGraphRemoveEdge( CvGraph* graph, int start_idx, int end_idx );
OPENCVAPI void cvGraphRemoveEdgeByPtr( CvGraph* graph, CvGraphVtx* start_vtx,
CvGraphVtx* end_vtx );
/* Find edge connecting two vertices */
OPENCVAPI CvGraphEdge* cvFindGraphEdge( CvGraph* graph, int start_idx, int end_idx );
OPENCVAPI CvGraphEdge* cvFindGraphEdgeByPtr( CvGraph* graph, CvGraphVtx* start_vtx,
CvGraphVtx* end_vtx );
#define cvGraphFindEdge cvFindGraphEdge
#define cvGraphFindEdgeByPtr cvFindGraphEdgeByPtr
/* Remove all vertices and edges from the graph */
OPENCVAPI void cvClearGraph( CvGraph* graph );
/* Count number of edges incident to the vertex */
OPENCVAPI int cvGraphVtxDegree( CvGraph* graph, int vtx_idx );
OPENCVAPI int cvGraphVtxDegreeByPtr( CvGraph* graph, 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 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;
/* Initializes graph traversal process.
<mask> indicates what events one wants to handle. */
OPENCVAPI void cvStartScanGraph( CvGraph* graph, CvGraphScanner* scanner,
CvGraphVtx* vtx CV_DEFAULT(NULL),
int mask CV_DEFAULT(CV_GRAPH_ALL_ITEMS));
/* Initializes graph traversal process.
<mask> indicates what events one wants to handle. */
OPENCVAPI void cvEndScanGraph( CvGraphScanner* scanner );
/* Get next graph element */
OPENCVAPI int cvNextGraphItem( CvGraphScanner* scanner );
/* Creates a copy of graph */
OPENCVAPI CvGraph* cvCloneGraph( const CvGraph* graph, CvMemStorage* storage );
/****************************************************************************************\
* Image Processing *
\****************************************************************************************/
/* Does look-up transformation. Elements of the source array
(that should be 8uC1 or 8sC1) are used as indexes in lutarr 256-element table */
OPENCVAPI void cvLUT( const CvArr* srcarr, CvArr* dstarr, const CvArr* lutarr );
/* Smoothes array (remove noise) */
#define CV_BLUR_NO_SCALE 0
#define CV_BLUR 1
#define CV_GAUSSIAN 2
#define CV_MEDIAN 3
#define CV_BILATERAL 4
OPENCVAPI void cvSmooth( const CvArr* srcarr, CvArr* dstarr,
int smoothtype CV_DEFAULT(CV_GAUSSIAN),
int param1 CV_DEFAULT(3),
int param2 CV_DEFAULT(0));
/* Finds integral image: SUM(X,Y) = sum(x<X,y<Y)I(x,y) */
OPENCVAPI void cvIntegral( const CvArr* image, CvArr* sumImage,
CvArr* sumSqImage CV_DEFAULT(NULL),
CvArr* tiltedSumImage CV_DEFAULT(NULL));
/*
Down-samples image with prior gaussian smoothing.
dst_width = floor(src_width/2)[+1],
dst_height = floor(src_height/2)[+1]
*/
OPENCVAPI void cvPyrDown( const CvArr* src, CvArr* dst,
int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
/*
Up-samples image with posterior gaussian smoothing.
dst_width = src_width*2,
dst_height = src_height*2
*/
OPENCVAPI void cvPyrUp( const CvArr* src, CvArr* dst,
int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
/* Builds the whole pyramid at once. Output array of CvMat headers (levels[*])
is initialized with the headers of subsequent pyramid levels */
/*OPENCVAPI void cvCalcPyramid( const CvArr* src, CvArr* container,
CvMat* levels, int levelCount,
int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );*/
/* Segments image using son-father links (modification of Burt's algorithm).
CvSeq<CvConnectedComp*> is returned to *comp */
OPENCVAPI void cvPyrSegmentation( IplImage* src,
IplImage* dst,
CvMemStorage *storage,
CvSeq **comp,
int level, double threshold1,
double threshold2 );
#define CV_SCHARR -1
/* calculates some image derivative using Sobel (apertureSize = 1,3,5,7)
or Scharr (apertureSize = -1) operator.
Scharr can be used only for the first dx or dy derivative */
OPENCVAPI void cvSobel( const CvArr* src, CvArr* dst,
int xorder, int yorder,
int apertureSize CV_DEFAULT(3));
/* Calculates Laplace operator: (d2/dx + d2/dy)I */
OPENCVAPI void cvLaplace( const CvArr* src, CvArr* dst,
int apertureSize CV_DEFAULT(3) );
/* Constants for color conversion */
#define CV_BGR2BGRA 0
#define CV_RGB2RGBA CV_BGR2BGRA
#define CV_BGRA2BGR 1
#define CV_RGBA2RGB CV_BGRA2BGR
#define CV_BGR2RGBA 2
#define CV_RGB2BGRA CV_BGR2RGBA
#define CV_RGBA2BGR 3
#define CV_BGRA2RGB CV_RGBA2BGR
#define CV_BGR2RGB 4
#define CV_RGB2BGR CV_BGR2RGB
#define CV_BGRA2RGBA 5
#define CV_RGBA2BGRA CV_BGRA2RGBA
#define CV_BGR2GRAY 6
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -