动态结构序列CvSeq是所有OpenCv动态数据结构的基础。有两种类型的序列:稠密序列,稀疏序列:
(1) 稠密序列都派生自CvSeq,他们用来代表可扩展的一维数组 — 向量、栈、队列和双端队列。数据间不存在空隙(连续存储)。如果元素元素从序列中间被删除或插入新的元素到序列,那么此元素后边的相关元素全部被移动。
(2)稀疏序列派生自CvSet,CvSet也是基于CvSeq的,他们都是由节点所组成,每一个节点要么被占用,那么为空,由标志位flag决定。这些序列作为无序数据结构被使用,如点集合、图、Hash表等。
结构CvSeq的具体定义如下:
struct CvSeq
Dynamically growing sequence.
int flags
sequence flags, including the sequence signature (CV_SEQ_MAGIC_VAL or CV_SET_MAGIC_VAL), type of the elements and some other information about the sequence.
int header_size
size of the sequence header. It should be sizeof(CvSeq) at minimum. See CreateSeq().
CvSeq* h_prev
CvSeq* h_next
CvSeq* v_prev
CvSeq* v_next
pointers to another sequences in a sequence tree. Sequence trees are used to store hierarchical contour structures, retrieved by FindContours()
int total
the number of sequence elements
int elem_size
size of each sequence element in bytes
CvMemStorage* storage
memory storage where the sequence resides. It can be a NULL pointer.
CvSeqBlock* first
pointer to the first data block
total表示稠密序列的元素个数,或者稀疏序列被分配的节点数。elem_size表示序列中每个元素占用的字节数。block_max是最近一个内存的最大边界指针。ptr表示当写指针。delta_elems表示序列间隔尺寸。storage指向序列存储的内存块的指针。free_blocks表示空的块列表。first指向第一个序列块。