CvSeq


CvSeq 에 대해서 알아보자.

C:\Program Files\OpenCV\docs\ref\opencvref_cxcore.htm (설치되어있을 경우에만, 확인바람)

사용되는 함수들

StartReadSeq()
void cvStartReadSeq( const CvSeq* seq, CvSeqReader* reader, int reverse=0 );
seq
Sequence.
reader
Reader state; initialized by the function.
reverse
Determines the direction of the sequence traversal. If reverse is 0, the reader is positioned at the first sequence element, otherwise it is positioned at the last element.
 

CvMemStorage* storage = cvCreateMemStorage(0);
CvSeq* seq = cvCreateSeq( CV_32SC1, sizeof(CvSeq), sizeof(int), storage );
CvSeqWriter writer;
CvSeqReader reader;
int i;

cvStartAppendToSeq( seq, &writer );
for( i = 0; i < 10; i++ )
{
    int val = rand()%100;
    CV_WRITE_SEQ_ELEM( val, writer );
    printf("%d is written\n", val );
}
cvEndWriteSeq( &writer );

cvStartReadSeq( seq, &reader, 0 );
for( i = 0; i < seq->total; i++ )
{
    int val;
#if 1
    CV_READ_SEQ_ELEM( val, reader );
    printf("%d is read\n", val );
#else /* alternative way, that is preferable if sequence elements are large,
         or their size/type is unknown at compile time */
    printf("%d is read\n", *(int*)reader.ptr );
    CV_NEXT_SEQ_ELEM( seq->elem_size, reader );
#endif
}
...

cvReleaseStorage( &storage );

'Library > opencv' 카테고리의 다른 글

오른손 좌표계, 왼손 좌표계  (0) 2010.11.23
[OpenCV] cvConvexHull2  (0) 2010.11.14
Hand Tracking  (0) 2010.11.05
OpenCV - 외곽선 추출(contour)  (0) 2010.11.05
OpenCV - 영상화전 cvGetQuadrangleSubPix()  (0) 2010.11.05

댓글

Designed by JB FACTORY