1.杂项标志位
CvSeq 结构中有一杂项标志位flags,这个标志里面某些标志可能要依赖其它位,才能确定最终意思。查看源代码,其值如下:
/****************************************************************************************\
* Sequence types *
\****************************************************************************************/
#define CV_SEQ_MAGIC_VAL 0x42990000
#define CV_IS_SEQ(seq) \
((seq) != NULL && (((CvSeq*)(seq))->flags & CV_MAGIC_MASK) == CV_SEQ_MAGIC_VAL)
#define CV_SET_MAGIC_VAL 0x42980000
#define CV_IS_SET(set) \
((set) != NULL && (((CvSeq*)(set))->flags & CV_MAGIC_MASK) == CV_SET_MAGIC_VAL)
#define CV_SEQ_ELTYPE_BITS 12
#define CV_SEQ_ELTYPE_MASK ((1 << CV_SEQ_ELTYPE_BITS) - 1)
#define CV_SEQ_ELTYPE_POINT CV_32SC2 /* (x,y) */
#define CV_SEQ_ELTYPE_CODE CV_8UC1 /* freeman code: 0..7 */
#define CV_SEQ_ELTYPE_GENERIC 0
#define CV_SEQ_ELTYPE_PTR CV_USRTYPE1
#define CV_SEQ_ELTYPE_PPOINT CV_SEQ_ELTYPE_PTR /* &(x,y) */
#define CV_SEQ_ELTYPE_INDEX CV_32SC1 /* #(x,y) */
#define CV_SEQ_ELTYPE_GRAPH_EDGE 0 /* &next_o, &next_d, &vtx_o, &vtx_d */
#define CV_SEQ_ELTYPE_GRAPH_VERTEX 0 /* first_edge, &(x,y) */
#define CV_SEQ_ELTYPE_TRIAN_ATR 0 /* vertex of the binary tree */
#define CV_SEQ_ELTYPE_CONNECTED_COMP 0 /* connected component */
#define CV_SEQ_ELTYPE_POINT3D CV_32FC3 /* (x,y,z) */
#define CV_SEQ_KIND_BITS 2
#define CV_SEQ_KIND_MASK (((1 << CV_SEQ_KIND_BITS) - 1)<<CV_SEQ_ELTYPE_BITS)
/* types of sequences */ //序列类型
#define CV_SEQ_KIND_GENERIC (0 << CV_SEQ_ELTYPE_BITS)
#define CV_SEQ_KIND_CURVE (1 << CV_SEQ_ELTYPE_BITS)
#define CV_SEQ_KIND_BIN_TREE (2 << CV_SEQ_ELTYPE_BITS)
/* types of sparse sequences (sets) *///稀疏序列的类型(sets)
#define CV_SEQ_KIND_GRAPH (1 << CV_SEQ_ELTYPE_BITS)
#define CV_SEQ_KIND_SUBDIV2D (2 << CV_SEQ_ELTYPE_BITS)
#define CV_SEQ_FLAG_SHIFT (CV_SEQ_KIND_BITS + CV_SEQ_ELTYPE_BITS)
/* flags for curves */
//曲线标志
#define CV_SEQ_FLAG_CLOSED (1 << CV_SEQ_FLAG_SHIFT)
#define CV_SEQ_FLAG_SIMPLE (0 << CV_SEQ_FLAG_SHIFT)
#define CV_SEQ_FLAG_CONVEX (0 << CV_SEQ_FLAG_SHIFT)
#define CV_SEQ_FLAG_HOLE (2 << CV_SEQ_FLAG_SHIFT)
/* flags for graphs */ //图像标志
#define CV_GRAPH_FLAG_ORIENTED (1 << CV_SEQ_FLAG_SHIFT)
#define CV_GRAPH CV_SEQ_KIND_GRAPH
#define CV_ORIENTED_GRAPH (CV_SEQ_KIND_GRAPH|CV_GRAPH_FLAG_ORIENTED)
/* point sets *///点设置
#define CV_SEQ_POINT_SET (CV_SEQ_KIND_GENERIC| CV_SEQ_ELTYPE_POINT)
#define CV_SEQ_POINT3D_SET (CV_SEQ_KIND_GENERIC| CV_SEQ_ELTYPE_POINT3D)
#define CV_SEQ_POLYLINE (CV_SEQ_KIND_CURVE | CV_SEQ_ELTYPE_POINT)
#define CV_SEQ_POLYGON (CV_SEQ_FLAG_CLOSED | CV_SEQ_POLYLINE )
#define CV_SEQ_CONTOUR CV_SEQ_POLYGON
#define CV_SEQ_SIMPLE_POLYGON (CV_SEQ_FLAG_SIMPLE | CV_SEQ_POLYGON )
/* chain-coded curves */ //曲线链编码
#define CV_SEQ_CHAIN (CV_SEQ_KIND_CURVE | CV_SEQ_ELTYPE_CODE)
#define CV_SEQ_CHAIN_CONTOUR (CV_SEQ_FLAG_CLOSED | CV_SEQ_CHAIN)
/* binary tree for the contour */ //二叉树的轮廓
#define CV_SEQ_POLYGON_TREE (CV_SEQ_KIND_BIN_TREE | CV_SEQ_ELTYPE_TRIAN_ATR)
/* sequence of the connected components *///序列的连接组件
#define CV_SEQ_CONNECTED_COMP (CV_SEQ_KIND_GENERIC | CV_SEQ_ELTYPE_CONNECTED_COMP)
/* sequence of the integer numbers */
#define CV_SEQ_INDEX (CV_SEQ_KIND_GENERIC | CV_SEQ_ELTYPE_INDEX)
#define CV_SEQ_ELTYPE( seq ) ((seq)->flags & CV_SEQ_ELTYPE_MASK)
#define CV_SEQ_KIND( seq ) ((seq)->flags & CV_SEQ_KIND_MASK )
/* flag checking *///标志检查
//索引标志
#define CV_IS_SEQ_INDEX( seq ) ((CV_SEQ_ELTYPE(seq) == CV_SEQ_ELTYPE_INDEX) && \
(CV_SEQ_KIND(seq) == CV_SEQ_KIND_GENERIC))
//是否是曲线
#define CV_IS_SEQ_CURVE( seq ) (CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE)
//闭合性
#define CV_IS_SEQ_CLOSED( seq ) (((seq)->flags & CV_SEQ_FLAG_CLOSED) != 0)
//是否是凸包
#define CV_IS_SEQ_CONVEX( seq ) 0
//是否是洞
#define CV_IS_SEQ_HOLE( seq ) (((seq)->flags & CV_SEQ_FLAG_HOLE) != 0)
#define CV_IS_SEQ_SIMPLE( seq ) 1
/* type checking macros */ //类型检查宏
#define CV_IS_SEQ_POINT_SET( seq ) \
((CV_SEQ_ELTYPE(seq) == CV_32SC2 || CV_SEQ_ELTYPE(seq) == CV_32FC2))
#define CV_IS_SEQ_POINT_SUBSET( seq ) \
(CV_IS_SEQ_INDEX( seq ) || CV_SEQ_ELTYPE(seq) == CV_SEQ_ELTYPE_PPOINT)
#define CV_IS_SEQ_POLYLINE( seq ) \
(CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE && CV_IS_SEQ_POINT_SET(seq))
#define CV_IS_SEQ_POLYGON( seq ) \
(CV_IS_SEQ_POLYLINE(seq) && CV_IS_SEQ_CLOSED(seq))
#define CV_IS_SEQ_CHAIN( seq ) \
(CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE && (seq)->elem_size == 1)
#define CV_IS_SEQ_CONTOUR( seq ) \
(CV_IS_SEQ_CLOSED(seq) && (CV_IS_SEQ_POLYLINE(seq) || CV_IS_SEQ_CHAIN(seq)))
#define CV_IS_SEQ_CHAIN_CONTOUR( seq ) \
(CV_IS_SEQ_CHAIN( seq ) && CV_IS_SEQ_CLOSED( seq ))
#define CV_IS_SEQ_POLYGON_TREE( seq ) \
(CV_SEQ_ELTYPE (seq) == CV_SEQ_ELTYPE_TRIAN_ATR && \
CV_SEQ_KIND( seq ) == CV_SEQ_KIND_BIN_TREE )
#define CV_IS_GRAPH( seq ) \
(CV_IS_SET(seq) && CV_SEQ_KIND((CvSet*)(seq)) == CV_SEQ_KIND_GRAPH)
#define CV_IS_GRAPH_ORIENTED( seq ) \
(((seq)->flags & CV_GRAPH_FLAG_ORIENTED) != 0)
#define CV_IS_SUBDIV2D( seq ) \
(CV_IS_SET(seq) && CV_SEQ_KIND((CvSet*)(seq)) == CV_SEQ_KIND_SUBDIV2D)
参考: gavin710 的 CvSeq 文章 http://blog.csdn.net/gavin710/article/details/7405437