当前位置: 首页>>代码示例>>C++>>正文


C++ cvStartReadSeq函数代码示例

本文整理汇总了C++中cvStartReadSeq函数的典型用法代码示例。如果您正苦于以下问题:C++ cvStartReadSeq函数的具体用法?C++ cvStartReadSeq怎么用?C++ cvStartReadSeq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cvStartReadSeq函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: findPairs

//Find all the matched points
void findPairs( const CvSeq* objectKeypoints,
                const CvSeq* objectDescriptors,
                const CvSeq* imageKeypoints,
                const CvSeq* imageDescriptors,
                std::vector<int>& ptpairs )
{
  int i;
  CvSeqReader reader, kreader;
  cvStartReadSeq( objectKeypoints, &kreader );
  cvStartReadSeq( objectDescriptors, &reader );
  ptpairs.clear();

  for( i = 0; i < objectDescriptors->total; i++ )
  {
    const CvSURFPoint* kp = (const CvSURFPoint*)kreader.ptr;
    const float* descriptor = (const float*)reader.ptr;
    CV_NEXT_SEQ_ELEM( kreader.seq->elem_size, kreader );
    CV_NEXT_SEQ_ELEM( reader.seq->elem_size, reader );
    int nearest_neighbor = naiveNearestNeighbor( descriptor,
						 kp->laplacian,
						 imageKeypoints,
						 imageDescriptors );
    if( nearest_neighbor >= 0 )
    {
      ptpairs.push_back(i);
      ptpairs.push_back(nearest_neighbor);
    }
  }
}
开发者ID:976717326,项目名称:visp,代码行数:30,代码来源:vpKeyPointSurf.cpp

示例2: findPairs

void
findPairs( const CvSeq* objectKeypoints, const CvSeq* objectDescriptors,
           const CvSeq* imageKeypoints, const CvSeq* imageDescriptors, struct pairList * ptpairs )
{
    CvSeqReader reader, kreader;
    cvStartReadSeq( objectKeypoints, &kreader , 0 );
    cvStartReadSeq( objectDescriptors, &reader , 0 );


    struct pairList * pairs = initializePairList(ptpairs,objectDescriptors->total);
    if (pairs==0) { fprintf(stderr,"Could not allocate enough memory for pointer pairs\n"); return ; }

    int i;
    for( i = 0; i < objectDescriptors->total; i++ )
    {
        const CvSURFPoint* kp = (const CvSURFPoint*)kreader.ptr;
        const float* descriptor = (const float*)reader.ptr;
        CV_NEXT_SEQ_ELEM( kreader.seq->elem_size, kreader );
        CV_NEXT_SEQ_ELEM( reader.seq->elem_size, reader );
        int nearest_neighbor = naiveNearestNeighbor( descriptor, kp->laplacian, imageKeypoints, imageDescriptors );
        if( nearest_neighbor >= 0 )
        {
            pairs->item[i].p1 = i;
            pairs->item[i].p2 = nearest_neighbor;
        }
    }

    destroyPairList(&pairs);
}
开发者ID:AmmarkoV,项目名称:AdvancedImageSearch,代码行数:29,代码来源:findObjectsSURF.c

示例3: cvStartReadSeq

void CvFaceElement::Energy()
{
    CvSeqReader reader, reader2;
    cvStartReadSeq( m_seqRects, &reader );
    for (int i = 0; i < m_seqRects->total; i++)
    {
        CvTrackingRect* pRect = (CvTrackingRect*)(reader.ptr);
        // outside and inside rects
        cvStartReadSeq( m_seqRects, &reader2 );
        for (int j = 0; j < m_seqRects->total; j++)
        {
            CvTrackingRect* pRect2 = (CvTrackingRect*)(reader2.ptr);
            if (i != j)
            {
                if (RectInRect(pRect2->r, pRect->r))
                    pRect->nRectsInThis ++;
                else if (pRect2->r.y + pRect2->r.height <= pRect->r.y)
                    pRect->nRectsOnTop ++;
                else if (pRect2->r.y >= pRect->r.y + pRect->r.height)
                    pRect->nRectsOnBottom ++;
                else if (pRect2->r.x + pRect2->r.width <= pRect->r.x)
                    pRect->nRectsOnLeft ++;
                else if (pRect2->r.x >= pRect->r.x + pRect->r.width)
                    pRect->nRectsOnRight ++;
            }
            CV_NEXT_SEQ_ELEM( sizeof(CvTrackingRect), reader2 );
        }
        // energy
        pRect->Energy(m_trPrev);
        CV_NEXT_SEQ_ELEM( sizeof(CvTrackingRect), reader );
    }
}//void CvFaceElement::Energy()
开发者ID:406089450,项目名称:opencv,代码行数:32,代码来源:vecfacetracking.cpp

示例4: naiveNearestNeighbor

int
naiveNearestNeighbor( const float* vec, int laplacian,
                      const CvSeq* model_keypoints,
                      const CvSeq* model_descriptors )
{
    int length = (int)(model_descriptors->elem_size/sizeof(float));
    int i, neighbor = -1;
    double d, dist1 = 1e6, dist2 = 1e6;
    CvSeqReader reader, kreader;
    cvStartReadSeq( model_keypoints, &kreader, 0 );
    cvStartReadSeq( model_descriptors, &reader, 0 );

    for( i = 0; i < model_descriptors->total; i++ )
    {
        const CvSURFPoint* kp = (const CvSURFPoint*)kreader.ptr;
        const float* mvec = (const float*)reader.ptr;
    	CV_NEXT_SEQ_ELEM( kreader.seq->elem_size, kreader );
        CV_NEXT_SEQ_ELEM( reader.seq->elem_size, reader );
        if( laplacian != kp->laplacian )
            continue;
        d = compareSURFDescriptors( vec, mvec, dist2, length );
        if( d < dist1 )
        {
            dist2 = dist1;
            dist1 = d;
            neighbor = i;
        }
        else if ( d < dist2 )
            dist2 = d;
    }
    if ( dist1 < 0.6*dist2 )
        return neighbor;
    return -1;
}
开发者ID:AmmarkoV,项目名称:AdvancedImageSearch,代码行数:34,代码来源:findObjectsSURF.c

示例5: WriteProtocol

/**
 * Write out a Protocol to YAML file, given an initialized CvFileStorage
 */
void WriteProtocol(Protocol* myP, CvFileStorage* fs){
	if (fs==0){
		printf("fs is zero! Could you have specified the wrong directory?\n");
		return;
	}
	/** Write out Protocol **/
	cvStartWriteStruct(fs,"Protocol",CV_NODE_MAP,NULL);
		if (myP->Filename!=NULL) cvWriteString(fs,"Filename",myP->Filename);
		if (myP->Description!=NULL)  cvWriteString(fs,"Description",myP->Description);
		cvStartWriteStruct(fs,"GridSize",CV_NODE_MAP,NULL);
			cvWriteInt(fs,"height",myP->GridSize.height);
			cvWriteInt(fs,"width",myP->GridSize.width);
		cvEndWriteStruct(fs);
		//printf("yo\n");
		/** Write Out Steps **/
		cvStartWriteStruct(fs,"Steps",CV_NODE_SEQ,NULL);
		int j;
		int jtot=myP->Steps->total;


		CvSeqReader StepReader;
		cvStartReadSeq(myP->Steps,&StepReader,0);
		for (j = 0; j < jtot; ++j) {
			//printf("About to write step number %d\n",j);
			CvSeq** CurrentMontagePtr = (CvSeq**) StepReader.ptr;
			CvSeq* CurrentMontage=*CurrentMontagePtr;
			assert(CurrentMontage!=NULL);
		//	printf("ping\n");
		//	printf("CurrentMontage->total=%d",CurrentMontage->total);
			cvStartWriteStruct(fs,NULL,CV_NODE_SEQ,NULL);
			int k;
			int ktot=CurrentMontage->total;
		//	printf("ktot=%d\n",ktot);

			CvSeqReader MontageReader;
			cvStartReadSeq(CurrentMontage,&MontageReader);
			for (k = 0; k < ktot; ++k) {
			//	printf("About to write polygon number %d\n",k);
				WormPolygon** CurrentPolygonPtr= (WormPolygon**) MontageReader.ptr;
				WormPolygon* CurrentPolygon=*CurrentPolygonPtr;

				cvWrite(fs,NULL,CurrentPolygon->Points);

				CV_NEXT_SEQ_ELEM(CurrentMontage->elem_size,MontageReader);
			}
			CurrentMontagePtr=NULL;
			CurrentMontage=NULL;
			cvEndWriteStruct(fs);

			/** Loop to Next Step **/
			CV_NEXT_SEQ_ELEM(myP->Steps->elem_size,StepReader);

		}
		cvEndWriteStruct(fs);
	cvEndWriteStruct(fs);
}
开发者ID:Sophrinix,项目名称:mindcontrol,代码行数:59,代码来源:IllumWormProtocol.c

示例6: VerifyProtocol

int VerifyProtocol(Protocol* p){
	printf("\n\n========== VERIFYING PROTOCOL============\n");
	if (p==NULL){
		printf("Protocol is NULL\n");
		return -1;
	}

	printf("Protocol description: %s\n", p->Description);
	printf("Filename= %s\n",p->Filename);
	printf("Total number of steps: p->Steps->total=%d\n",p->Steps->total);

	CvSeqReader StepReader;
	cvStartReadSeq(p->Steps, &StepReader,0);
	int numsteps=p->Steps->total;
	/** Let's loop through all of the steps **/
		for (int i= 0; i< numsteps; ++i) {
			printf("Step i=%d\n",i);

			CvSeq* CurrMontage= *( (CvSeq**) StepReader.ptr);
			printf("\tCurrMontage has %d polygons\n",CurrMontage->total);
			int numPolygons=CurrMontage->total;
			int j;


			/** Let's loop through the polygons **/

			CvSeqReader MontageReader;
			cvStartReadSeq(CurrMontage, &MontageReader);
			for (j = 0; j < numPolygons; ++j) {
				WormPolygon*  poly= *( (WormPolygon**) MontageReader.ptr );
				int numpts=poly->Points->total;
				printf(" numpts=%d\n",numpts);




				//PrintPointsOfSeq(poly->Points);




				CV_NEXT_SEQ_ELEM( CurrMontage->elem_size,MontageReader);
			}




			/** Progress to the next step **/
			CV_NEXT_SEQ_ELEM( p->Steps->elem_size, StepReader );
		}


	printf("========================================\n");
	return 0;
}
开发者ID:Sophrinix,项目名称:mindcontrol,代码行数:55,代码来源:IllumWormProtocol.c

示例7: matchingORB

void matchingORB(const CvSeq* sd, const CvSeq* id, std::vector<int> &pairs) {

    int i, j, k, d1, d2, jj, dist, i_total, s_total;
    unsigned char *i_ptr, *s_ptr;

    CvSeqReader i_reader;
    CvSeqReader s_reader;

    i_total = id->total;
    s_total = sd->total;

    cvStartReadSeq(sd, &s_reader, 0);
    s_ptr = (unsigned char*) s_reader.ptr;

    for(i=0; i<s_total; i++) {

        d1 = d2 = 0;
        jj = -1;

        cvStartReadSeq(id, &i_reader, 0);
        i_ptr = (unsigned char*) i_reader.ptr;

        for(j=0; j<i_total; j++) {

            dist = 0;

            for(k=0; k<32; k++)
                dist += (s_ptr[k]==i_ptr[k]) ? 1 : 0;

            if(dist>d1) {
                d2 = d1;
                d1 = dist;
                jj = j;
            }
            else if(dist>d2)
                d2 = dist;

            CV_NEXT_SEQ_ELEM(i_reader.seq->elem_size, i_reader);
            i_ptr = (unsigned char*) i_reader.ptr;

        }

        if((jj>=0) && (d2 < 0.7*d1)) {
            pairs.push_back(i);
            pairs.push_back(jj);
        }

        CV_NEXT_SEQ_ELEM(s_reader.seq->elem_size, s_reader);
        s_ptr = (unsigned char*) s_reader.ptr;

    }
}
开发者ID:Modasshir,项目名称:socrob-ros-pkg,代码行数:52,代码来源:matching.cpp

示例8: cvClearSubdivVoronoi2D

CV_IMPL void
cvClearSubdivVoronoi2D( CvSubdiv2D * subdiv )
{
    int elem_size;
    int i, total;
    CvSeqReader reader;

    CV_FUNCNAME( "cvClearVoronoi2D" );

    __BEGIN__;

    if( !subdiv )
        CV_ERROR( CV_StsNullPtr, "" );

    /* clear pointers to voronoi points */
    total = subdiv->edges->total;
    elem_size = subdiv->edges->elem_size;

    cvStartReadSeq( (CvSeq *) (subdiv->edges), &reader, 0 );

    for( i = 0; i < total; i++ )
    {
        CvQuadEdge2D *quadedge = (CvQuadEdge2D *) reader.ptr;

        quadedge->pt[1] = quadedge->pt[3] = 0;
        CV_NEXT_SEQ_ELEM( elem_size, reader );
    }

    /* remove voronoi points */
    total = subdiv->total;
    elem_size = subdiv->elem_size;

    cvStartReadSeq( (CvSeq *) subdiv, &reader, 0 );

    for( i = 0; i < total; i++ )
    {
        CvSubdiv2DPoint *pt = (CvSubdiv2DPoint *) reader.ptr;

        /* check for virtual point. it is also check that the point exists */
        if( pt->flags & CV_SUBDIV2D_VIRTUAL_POINT_FLAG )
        {
            cvSetRemoveByPtr( (CvSet*)subdiv, pt );
        }
        CV_NEXT_SEQ_ELEM( elem_size, reader );
    }

    subdiv->is_geometry_valid = 0;

    
    __END__;
}
开发者ID:cybertk,项目名称:opencv,代码行数:51,代码来源:cvsubdivision2d.cpp

示例9: cvStartReadRawData

CV_IMPL void
cvStartReadRawData( const CvFileStorage* fs, const CvFileNode* src, CvSeqReader* reader )
{
    int node_type;
    CV_CHECK_FILE_STORAGE( fs );

    if( !src || !reader )
        CV_Error( CV_StsNullPtr, "Null pointer to source file node or reader" );

    node_type = CV_NODE_TYPE(src->tag);
    if( node_type == CV_NODE_INT || node_type == CV_NODE_REAL )
    {
        // emulate reading from 1-element sequence
        reader->ptr = (schar*)src;
        reader->block_max = reader->ptr + sizeof(*src)*2;
        reader->block_min = reader->ptr;
        reader->seq = 0;
    }
    else if( node_type == CV_NODE_SEQ )
    {
        cvStartReadSeq( src->data.seq, reader, 0 );
    }
    else if( node_type == CV_NODE_NONE )
    {
        memset( reader, 0, sizeof(*reader) );
    }
    else
        CV_Error( CV_StsBadArg, "The file node should be a numerical scalar or a sequence" );
}
开发者ID:Achraf33,项目名称:opencv,代码行数:29,代码来源:persistence_c.cpp

示例10: cvStartReadChainPoints

CV_IMPL void
cvStartReadChainPoints( CvChain * chain, CvChainPtReader * reader )
{
    int i;

    CV_FUNCNAME( "cvStartReadChainPoints" );

    __BEGIN__;

    if( !chain || !reader )
        CV_ERROR( CV_StsNullPtr, "" );

    if( chain->elem_size != 1 || chain->header_size < (int)sizeof(CvChain))
        CV_ERROR_FROM_STATUS( CV_BADSIZE_ERR );

    cvStartReadSeq( (CvSeq *) chain, (CvSeqReader *) reader, 0 );
    CV_CHECK();

    reader->pt = chain->origin;

    for( i = 0; i < 8; i++ )
    {
        reader->deltas[i][0] = (char) icvCodeDeltas[i].x;
        reader->deltas[i][1] = (char) icvCodeDeltas[i].y;
    }

    __END__;
}
开发者ID:DORARA29,项目名称:AtomManipulator,代码行数:28,代码来源:cvcontours.cpp

示例11: drawSquares

// the function draws all the squares in the image 
void drawSquares( IplImage* img, CvSeq* squares ) {  
	CvSeqReader reader; 
	IplImage* cpy = cvCloneImage( img );
	int i;  
	// initialize reader of the sequence 
	cvStartReadSeq( squares, &reader, 0 );
	// read 4 sequence elements at a time (all vertices of a square)  
	for( i = 0; i < squares->total; i += 4 ){  
		CvPoint* rect = pt;
		int count = 4; 
		// read 4 vertices  
		memcpy( pt, reader.ptr, squares->elem_size );
		CV_NEXT_SEQ_ELEM( squares->elem_size, reader ); 
		memcpy( pt + 1, reader.ptr, squares->elem_size );  
		CV_NEXT_SEQ_ELEM( squares->elem_size, reader );
		memcpy( pt + 2, reader.ptr, squares->elem_size );
		CV_NEXT_SEQ_ELEM( squares->elem_size, reader );  
		memcpy( pt + 3, reader.ptr, squares->elem_size ); 
		CV_NEXT_SEQ_ELEM( squares->elem_size, reader ); 
		// draw the square as a closed polyline 
		cvPolyLine( cpy, &rect, &count, 1, 1, CV_RGB(0,255,0), 3, CV_AA, 0 );
		if(i == 0){
			sort_vertex(rect);    //get the four vertex and sort them
			break;
		}
	}  
	// show the resultant image  
	cvShowImage( wndname, cpy );
	cvReleaseImage( &cpy ); 
} 
开发者ID:guoqi1123,项目名称:ProjectionCompensation,代码行数:31,代码来源:rectangle.cpp

示例12: paint_voronoi

void paint_voronoi( CvSubdiv2D* subdiv, IplImage* img )
{
    CvSeqReader  reader;
    int i, total = subdiv->edges->total;
    int elem_size = subdiv->edges->elem_size;

    cvCalcSubdivVoronoi2D( subdiv );

    cvStartReadSeq( (CvSeq*)(subdiv->edges), &reader, 0 );

    for( i = 0; i < total; i++ )
    {
        CvQuadEdge2D* edge = (CvQuadEdge2D*)(reader.ptr);

        if( CV_IS_SET_ELEM( edge ))
        {
            CvSubdiv2DEdge e = (CvSubdiv2DEdge)edge;
            // left
            draw_subdiv_facet( img, cvSubdiv2DRotateEdge( e, 1 ));

            // right
            draw_subdiv_facet( img, cvSubdiv2DRotateEdge( e, 3 ));
        }

        CV_NEXT_SEQ_ELEM( elem_size, reader );
    }
}
开发者ID:Ashwini7,项目名称:smart-python-programs,代码行数:27,代码来源:delaunay.c

示例13: cvStartReadSeq

/** Draws the identified Tetris pieces on the given image.
 */
void Camera::drawTetris( IplImage* img, CvSeq* tetrisPieces )
{
    CvSeqReader reader;
    int i;

    // initialize reader of the sequence
    cvStartReadSeq( tetrisPieces, &reader, 0 );

    // read the pieces sequence elements at a time (all vertices of the piece)
    for( i = 0; i < tetrisPieces->total; i += 6 )
    {
        CvPoint pt[6], *rect = pt;
        int count = 6;

        // read 6 vertices
        CV_READ_SEQ_ELEM( pt[0], reader );
        CV_READ_SEQ_ELEM( pt[1], reader );
        CV_READ_SEQ_ELEM( pt[2], reader );
        CV_READ_SEQ_ELEM( pt[3], reader );
        CV_READ_SEQ_ELEM( pt[4], reader );
        CV_READ_SEQ_ELEM( pt[5], reader );


        // draw the piece as a closed polyline
        cvPolyLine( img, &rect, &count, 1, 1, CV_RGB(255,0,0), 3, CV_AA, 0 );
    }

	return;
}
开发者ID:JackFan-Z,项目名称:MetroVision,代码行数:31,代码来源:camera.cpp

示例14: CV_FUNCNAME

void
Blob::copy_edges(const CvSeq* _edges)
{
  CV_FUNCNAME( "Blob::copy_edges" );
  __BEGIN__;

	cvClearSeq(this->edges_);
  
  //- copy the given sequence
	CvSeqReader seq_reader;
	CvSeqWriter seq_writer;
	CvPoint current_edge;
  int i;

	CV_CALL( cvStartReadSeq( _edges, &seq_reader) );
	CV_CALL( cvStartAppendToSeq( this->edges_, &seq_writer ) );

	for( i = 0; i < _edges->total; i++)
	{
		CV_READ_SEQ_ELEM ( current_edge , seq_reader);
		CV_WRITE_SEQ_ELEM( current_edge , seq_writer );
	}

	CV_CALL( cvEndWriteSeq( &seq_writer ) );


  __END__;
  __ISL_CHECK_ERROR__;
}
开发者ID:srgblnch,项目名称:ISL,代码行数:29,代码来源:Blob.cpp

示例15: icvSeqElemsClearMask

static  void  icvSeqElemsClearMask( CvSeq* seq, int offset, int clear_mask )
{
    CV_FUNCNAME("icvStartScanGraph");

    __BEGIN__;
    
    CvSeqReader reader;
    int i, total, elem_size;

    if( !seq )
        CV_ERROR_FROM_STATUS( CV_NULLPTR_ERR );

    elem_size = seq->elem_size;
    total = seq->total;

    if( (unsigned)offset > (unsigned)elem_size )
        CV_ERROR_FROM_STATUS( CV_BADARG_ERR );

    CV_CALL( cvStartReadSeq( seq, &reader ));

    for( i = 0; i < total; i++ )
    {
        int* flag_ptr = (int*)(reader.ptr + offset);
        *flag_ptr &= ~clear_mask;

        CV_NEXT_SEQ_ELEM( elem_size, reader );
    }

    __END__;
}
开发者ID:mikanradojevic,项目名称:sdkpub,代码行数:30,代码来源:cvgraphex.cpp


注:本文中的cvStartReadSeq函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。