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


C++ CV_READ_SEQ_ELEM函数代码示例

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


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

示例1: drawSquares

void drawSquares(IplImage* img, CvSeq* squares, PointMatrix &mat)
{
        CvSeqReader reader;
        IplImage* cpy = cvCloneImage(img);

        cvStartReadSeq(squares, &reader, 0);

        for (int i = 0; i < squares->total; i++) {
                CvPoint pt[4], *rect = pt;
                int count = 4;
                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);

                cvLine(cpy, pt[0], pt[2], CV_RGB(0, 0, 0), 1);
                cvLine(cpy, pt[1], pt[3], CV_RGB(255, 255, 0), 1);

                MyCvPoint myCvPoint( (pt[0].x + pt[2].x) /2, (pt[1].y + pt[2].y)/2, img->width, img->height);

                mat.AddMem(myCvPoint);

                cvPolyLine(cpy, &rect, &count, 1, 1, CV_RGB(0, 255, 255), 1, 8, 0);
        }
       // cvShowImage("After Modify", cpy);
        cvReleaseImage(&cpy);
}
开发者ID:corvofeng,项目名称:cube,代码行数:27,代码来源:Utils.cpp

示例2: cvStartReadSeq

void EyeTracker::drawSquares(CvSeq* squares)
{
	CvSeqReader reader;
	int i;

	// initialize reader of the sequence
	cvStartReadSeq(squares, &reader, 0);
	CvPoint pt[4];
	CvPoint* rect;

	// read 4 sequence elements at a time (all vertices of a square)
	for(i = 0; i < squares->total; i += 4)
	{
		rect = pt;
		int count = 4;

		// read 4 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);

		cvPolyLine(graySceneImagePts, &rect, &count, 1, 1, CV_RGB(255, 255, 255), 3, CV_AA, 0);
	}

	CvFont font;
	cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX | CV_FONT_ITALIC, 1.0, 1.0, 0, 1);

	char s[20];
	sprintf(s, "Threshold = %d", squareThreshold);

	cvPutText(graySceneImagePts, s, cvPoint(30, 30), &font, cvScalar(255, 255, 0));
}
开发者ID:burakkoray,项目名称:EyeTracker,代码行数:33,代码来源:EyeTracker.cpp

示例3: 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

示例4: cvStartReadSeq

double BlobGetMaxYatMinX::operator()(Blob &blob)
{
	double result = LONG_MIN;

	CvSeqReader reader;
	CvPoint actualPoint;
	BlobContour::t_PointList externContour;

	externContour = blob.GetExternalContour()->GetContourPoints();
	if( !externContour ) return result;

	cvStartReadSeq( externContour, &reader);


	for( int i=0; i< externContour->total; i++)
	{
		CV_READ_SEQ_ELEM( actualPoint, reader);

		if( (actualPoint.x == blob.MinX()) && (actualPoint.y > result) )
		{
			result = actualPoint.y;
		}
	}

	return result;
}
开发者ID:DisCODe,项目名称:DCL_CvBlobs,代码行数:26,代码来源:BlobOperators.cpp

示例5: operator

    virtual void operator()(const cv::BlockedRange& range) const
    {
#ifdef HAVE_TBB
        tbb::spin_mutex::scoped_lock lock;
#endif
        CvSeqReader reader;
        int begin = range.begin();
        int end = range.end();

        int weak_count = end - begin;
        CvDTree* tree;

        for (int i=0; i<k; ++i)
        {
            float tmp_sum = 0.0f;
            if ((weak[i]) && (weak_count))
            {
                cvStartReadSeq( weak[i], &reader );
                cvSetSeqReaderPos( &reader, begin );
                for (int j=0; j<weak_count; ++j)
                {
                    CV_READ_SEQ_ELEM( tree, reader );
                    tmp_sum += shrinkage*(float)(tree->predict(sample, missing)->value);
                }
            }
#ifdef HAVE_TBB
            lock.acquire(SumMutex);
            sum[i] += tmp_sum;
            lock.release();
#else
            sum[i] += tmp_sum;
#endif
        }
    } // Tree_predictor::operator()
开发者ID:Rocky030,项目名称:opencv,代码行数:34,代码来源:gbt.cpp

示例6: maskFromTemplate

std::vector<CvPoint>
maskFromTemplate (const std::vector<cv::linemod::Template>& templates,
                  int num_modalities,
                  cv::Point offset,
                  cv::Size size,
                  cv::Mat& mask,
                  cv::Mat& dst)
{
  templateConvexHull (templates, num_modalities, offset, size, mask);

  const int OFFSET = 30;
  cv::dilate (mask, mask, cv::Mat (), cv::Point (-1, -1), OFFSET);

  CvMemStorage * lp_storage = cvCreateMemStorage (0);
  CvTreeNodeIterator l_iterator;
  CvSeqReader l_reader;
  CvSeq * lp_contour = 0;

  cv::Mat mask_copy = mask.clone ();
  IplImage mask_copy_ipl = mask_copy;
  cvFindContours (&mask_copy_ipl, lp_storage, &lp_contour, sizeof(CvContour), CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);

  std::vector<CvPoint> l_pts1;  // to use as input to cv_primesensor::filter_plane

  cvInitTreeNodeIterator (&l_iterator, lp_contour, 1);
  while ( (lp_contour = (CvSeq *) cvNextTreeNode (&l_iterator)) != 0)
  {
    CvPoint l_pt0;
    cvStartReadSeq (lp_contour, &l_reader, 0);
    CV_READ_SEQ_ELEM(l_pt0, l_reader);
    l_pts1.push_back (l_pt0);

    for (int i = 0; i < lp_contour->total; ++i)
    {
      CvPoint l_pt1;
      CV_READ_SEQ_ELEM(l_pt1, l_reader);
      /// @todo Really need dst at all? Can just as well do this outside
      cv::line (dst, l_pt0, l_pt1, CV_RGB(0, 255, 0), 2);

      l_pt0 = l_pt1;
      l_pts1.push_back (l_pt0);
    }
  }
  cvReleaseMemStorage (&lp_storage);

  return l_pts1;
}
开发者ID:nqanh,项目名称:moveit_bigman,代码行数:47,代码来源:test_linemod_opencv.cpp

示例7: vectorPunts

/**
- FUNCTION: FillBlob
- FUNCTIONALITY: 
	- Fills the blob with a specified colour
- PARAMETERS:
	- imatge: where to paint
	- color: colour to paint the blob
- RESULT:
	- modifies input image and returns the seed point used to fill the blob
- RESTRICTIONS:
- AUTHOR: Ricard Borr�
- CREATION DATE: 25-05-2005.
- MODIFICATION: Date. Author. Description.
*/
void CBlob::FillBlob( IplImage *imatge, CvScalar color, int offsetX /*=0*/, int offsetY /*=0*/) const					  
{
	
	//verifiquem que existeixi el blob i que tingui cantonades
	if( edges == NULL || edges->total == 0 ) return;
	
	CvPoint edgeactual, pt1, pt2;
	CvSeqReader reader;
	vectorPunts vectorEdges = vectorPunts( edges->total );
	vectorPunts::iterator itEdges, itEdgesSeguent;
	bool dinsBlob;
	int yActual;
	
	// passem els punts del blob a un vector de punts de les STL
	cvStartReadSeq( edges, &reader);
	itEdges = vectorEdges.begin();
	while( itEdges != vectorEdges.end() )
	{
		CV_READ_SEQ_ELEM( edgeactual ,reader);
		*itEdges = edgeactual;
		itEdges++;
	}
	// ordenem el vector per les Y's i les X's d'esquerra a dreta
	std::sort( vectorEdges.begin(), vectorEdges.end(), comparaCvPoint() );

	// recorrem el vector ordenat i fem linies entre punts consecutius
	itEdges = vectorEdges.begin();
	itEdgesSeguent = vectorEdges.begin() + 1;
	dinsBlob = true;
	while( itEdges != (vectorEdges.end() - 1))
	{
		yActual = (*itEdges).y;

		if( ( (*itEdges).x != (*itEdgesSeguent).x ) &&
			( (*itEdgesSeguent).y == yActual )
		  )
		{
			if( dinsBlob )
			{
				pt1 = *itEdges;
				pt1.x += offsetX;
				pt1.y += offsetY;

				pt2 = *itEdgesSeguent;
				pt2.x += offsetX;
				pt2.y += offsetY;

				cvLine( imatge, pt1, pt2, color );
			}
			dinsBlob =! dinsBlob;
		}
		itEdges++;
		itEdgesSeguent++;
		if( (*itEdges).y != yActual ) dinsBlob = true;
	}
	vectorEdges.clear();
}
开发者ID:Karma-Revolutions,项目名称:icub-main,代码行数:71,代码来源:Blob.cpp

示例8: cvApproxChains

//! Calculate contour points from crack codes
t_PointList CBlobContour::GetContourPoints()
{
	// it is calculated?
	if( m_contourPoints != NULL )
		return m_contourPoints;

	if ( m_contour == NULL || m_contour->total <= 0 )
	{
		return NULL;
	}

	CvSeq *tmpPoints;
	CvSeqReader reader;
	CvSeqWriter writer;
	CvPoint actualPoint;
	CvRect boundingBox;

	// if aproximation is different than simple extern perimeter will not work
	tmpPoints = cvApproxChains( m_contour, m_parentStorage, CV_CHAIN_APPROX_NONE);


	// apply an offset to contour points to recover real coordinates
	
	cvStartReadSeq( tmpPoints, &reader);

	m_contourPoints = cvCreateSeq( tmpPoints->flags, tmpPoints->header_size, tmpPoints->elem_size, m_parentStorage );
	cvStartAppendToSeq(m_contourPoints, &writer );

	// also calculate bounding box of the contour to allow cvPointPolygonTest
	// work correctly on the generated polygon
	boundingBox.x = boundingBox.y = 10000;
	boundingBox.width = boundingBox.height = 0;
	
	for( int i=0; i< tmpPoints->total; i++)
	{
		CV_READ_SEQ_ELEM( actualPoint, reader);

		actualPoint.x += m_startPoint.x;
		actualPoint.y += m_startPoint.y;

		boundingBox.x = MIN( boundingBox.x, actualPoint.x );
		boundingBox.y = MIN( boundingBox.y, actualPoint.y );
		boundingBox.width = MAX( boundingBox.width, actualPoint.x );
		boundingBox.height = MAX( boundingBox.height, actualPoint.y );
		
		CV_WRITE_SEQ_ELEM( actualPoint, writer );
	}
	cvEndWriteSeq( &writer );
	cvClearSeq( tmpPoints );

	// assign calculated bounding box
	((CvContour*)m_contourPoints)->rect = boundingBox;


	return m_contourPoints;
}
开发者ID:rgleichman,项目名称:berkeley_demos,代码行数:57,代码来源:BlobContour.cpp

示例9: computeSeqReprojError

void computeSeqReprojError( CvSeq *seq, CvMat *model, double *error )
{
  CvSeqReader reader;
  Match_t match;
  cvStartReadSeq( seq, &reader, 0 );
  for( int i = 0; i < seq->total; i ++ ) {
    CV_READ_SEQ_ELEM( match, reader );
    error[i] = computeReprojError( &match, model );
  }
}
开发者ID:JohanJohansson,项目名称:opencv-ffi-ext,代码行数:10,代码来源:matcher_helper.cpp

示例10: cvClearSeq

/**
- FUNCTION: Assigment operator
- FUNCTIONALITY: Assigns a blob to the current 
- PARAMETERS:
	- src: blob to assign
- RESULT:
	- the current blob is replaced by the src blob
- RESTRICTIONS:
- AUTHOR: Ricard Borr�
- CREATION DATE: 25-05-2005.
- MODIFICATION: Date. Author. Description.
*/
CBlob& CBlob::operator=(const CBlob &src )
{
	// si ja s� el mateix, no cal fer res
	if (this != &src)
	{
		// Eliminar v�texs del blob 
		cvClearSeq(edges);
		// i la zona de mem�ia on s�
		cvReleaseMemStorage( &m_storage );

		// creem una sequencia buida per als edges
		m_storage = cvCreateMemStorage(0);
		edges = cvCreateSeq( CV_SEQ_KIND_GENERIC|CV_32SC2,
								   sizeof(CvContour),
								   sizeof(CvPoint),m_storage);

		// copiem les propietats del blob origen a l'actual
		etiqueta = src.etiqueta;		
		exterior = src.exterior;
		area = src.Area();
		perimeter = src.Perimeter();
		parent = src.parent;
		minx = src.minx;
		maxx = src.maxx;
		miny = src.miny;
		maxy = src.maxy;
		sumx = src.sumx;
		sumy = src.sumy;
		sumxx = src.sumxx;
		sumyy = src.sumyy;
		sumxy = src.sumxy;
		mean = src.mean;
		stddev = src.stddev;
		externPerimeter = src.externPerimeter;

		// copiem els edges del blob origen a l'actual
		CvSeqReader reader;
		CvSeqWriter writer;
		CvPoint edgeactual;
		
		cvStartReadSeq( src.Edges(), &reader);
		cvStartAppendToSeq( edges, &writer );

		for( int i=0; i< src.Edges()->total; i++)
		{
			CV_READ_SEQ_ELEM( edgeactual ,reader);
			CV_WRITE_SEQ_ELEM( edgeactual , writer );
		}
		
		cvEndWriteSeq( &writer );
	}
	return *this;
}
开发者ID:Karma-Revolutions,项目名称:icub-main,代码行数:65,代码来源:Blob.cpp

示例11: 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

示例12: box

/**
- FUNCIÓ: GetBoundingBox
- FUNCIONALITAT: Get bounding box (without rotation) of a blob
- PARÀMETRES:
	- 
- RESULTAT:
	- 
- RESTRICCIONS:
	- 
- AUTOR: rborras
- DATA DE CREACIÓ: 2008/05/06
- MODIFICACIÓ: Data. Autor. Descripció.
*/
CvRect CBlob::GetBoundingBox()
{
	// it is calculated?
	if( m_boundingBox.width != -1 )
	{
		return m_boundingBox;
	}

	t_PointList externContour;
	CvSeqReader reader;
	CvPoint actualPoint;
	
	// get contour pixels
	externContour = m_externalContour.GetContourPoints();
	
	// it is an empty blob?
	if( !externContour )
	{
		m_boundingBox.x = 0;
		m_boundingBox.y = 0;
		m_boundingBox.width = 0;
		m_boundingBox.height = 0;

		return m_boundingBox;
	}

	cvStartReadSeq( externContour, &reader);

	m_boundingBox.x = m_originalImageSize.width;
	m_boundingBox.y = m_originalImageSize.height;
	m_boundingBox.width = 0;
	m_boundingBox.height = 0;

	for( int i=0; i< externContour->total; i++)
	{
		CV_READ_SEQ_ELEM( actualPoint, reader);

		m_boundingBox.x = MIN( actualPoint.x, m_boundingBox.x );
		m_boundingBox.y = MIN( actualPoint.y, m_boundingBox.y );
		
		m_boundingBox.width = MAX( actualPoint.x, m_boundingBox.width );
		m_boundingBox.height = MAX( actualPoint.y, m_boundingBox.height );
	}

	//m_boundingBox.x = max( m_boundingBox.x , 0 );
	//m_boundingBox.y = max( m_boundingBox.y , 0 );

	m_boundingBox.width -= m_boundingBox.x;
	m_boundingBox.height -= m_boundingBox.y;
	
	return m_boundingBox;
}
开发者ID:ashokzg,项目名称:billiards,代码行数:65,代码来源:Blob.cpp

示例13: cvStartReadSeq

/**
- FUNCTION: BlobGetXYInside
- FUNCTIONALITY: Calculates whether a point is inside the
    rectangular bounding box of a blob
- PARAMETERS:
- RESULT:
	- returns 1 if it is inside; o if not
- RESTRICTIONS:
- AUTHOR: Francesc Pinyol Margalef
- CREATION DATE: 16-01-2006.
- MODIFICATION: Date. Author. Description.
*/
double CBlobGetXYInside::operator()(const CBlob &blob) const
{
	if( blob.Edges() == NULL || blob.Edges()->total == 0 ) return 0.0;
	
	// passem els punts del blob a un vector de punts de les STL
	CvSeqReader reader;
	CBlob::vectorPunts vectorEdges;
	CBlob::vectorPunts::iterator itEdges, itEdgesSeguent;
	CvPoint edgeactual;
	bool dinsBlob;
	
	// agafem tots els punts amb la mateixa y que l'actual
	cvStartReadSeq( blob.Edges(), &reader);
	
	for( int i=0; i< blob.Edges()->total; i++)
	{
		CV_READ_SEQ_ELEM( edgeactual ,reader );
		if( edgeactual.y == m_p.y )
			vectorEdges.push_back( edgeactual );
	}

	if( vectorEdges.size() == 0 ) return 0.0;

	// ordenem el vector per les Y's i les X's d'esquerra a dreta
	std::sort( vectorEdges.begin(), vectorEdges.end(), CBlob::comparaCvPoint() );

	// recorrem el punts del blob de la mateixa fila que el punt d'entrada
	// i mirem si la X del punt d'entrada est�entre dos coordenades "plenes"
	// del blob
	itEdges = vectorEdges.begin();
	itEdgesSeguent = vectorEdges.begin() + 1;
	dinsBlob = true;

	while( itEdges != (vectorEdges.end() - 1) )
	{
		if( (*itEdges).x <= m_p.x && (*itEdgesSeguent).x >= m_p.x && dinsBlob )
		{
			vectorEdges.clear();
			return 1.0;
		}

		itEdges++;
		itEdgesSeguent++;
		dinsBlob = !dinsBlob;
	}

	vectorEdges.clear();
	return 0.0;
}
开发者ID:Karma-Revolutions,项目名称:icub-main,代码行数:61,代码来源:Blob.cpp

示例14: cvBoundingRect

/**
 * @internal
 * Extracts the relevant information of the found blobs
 * @note when this method is called, the found blobs should be stored in m_blobs member
 */
void BlobFinder::extractBlobsInformation()
{
  // Order blobs (from bigger to smaller) -> this way the most relevant are at the beginning
  std::sort( m_blobs.begin(), m_blobs.end(), std::greater< Blob >() );

  // Discard blobs (if there is more than the max)
  // TODO

  // To store contour moments
  CvMoments moment;

  // to read contour points
	CvSeqReader contourReader;
	CvPoint		  contourNode;

  // Calculate information about contours
  for( Blobs::size_type i = 0; (i < m_blobs.size()) && (i < m_maxBlobs); ++i )
  {
      // Current blob
      Blob& blob = m_blobs[ i ];

      // Get bbox
      blob.bbox = cvBoundingRect( blob.contour );

      // Get center through moments
      cvMoments( blob.contour, &moment );
      blob.center.x = (float)(moment.m10 / moment.m00);
      blob.center.y = (float)(moment.m01 / moment.m00);

      // Invert Y coordinate because our Y 0 is at top of the image,
      // and for Opencv is at the bottom of the image
      //blob.center.Y = inImage.GetHeight() - blob.center.Y;

    // Store the contour nodes
    cvStartReadSeq( blob.contour, &contourReader );
    for( int j = 0; j < blob.contour->total; ++j )
    {
	    // Read node of the contour
	    CV_READ_SEQ_ELEM( contourNode, contourReader );
	    blob.nodes.push_back( Point( (float)contourNode.x, (float)contourNode.y , 0) );
    }
  }

	// Store number of actual blobs
	m_nBlobs = min( (int)m_blobs.size(), (int)m_maxBlobs );
}
开发者ID:space150,项目名称:space150-Cing,代码行数:51,代码来源:BlobFinder.cpp

示例15: cvSliceLength

void CvGBTrees::clear()
{
    if( weak )
    {
        CvSeqReader reader;
        CvSlice slice = CV_WHOLE_SEQ;
        CvDTree* tree;

        //data->shared = false;
        for (int i=0; i<class_count; ++i)
        {
            int weak_count = cvSliceLength( slice, weak[i] );
            if ((weak[i]) && (weak_count))
            {
                cvStartReadSeq( weak[i], &reader );
                cvSetSeqReaderPos( &reader, slice.start_index );
                for (int j=0; j<weak_count; ++j)
                {
                    CV_READ_SEQ_ELEM( tree, reader );
                    //tree->clear();
                    delete tree;
                    tree = 0;
                }
            }
        }
        for (int i=0; i<class_count; ++i)
            if (weak[i]) cvReleaseMemStorage( &(weak[i]->storage) );
        delete[] weak;
    }
    if (data)
    {
        data->shared = false;
        delete data;
    }
    weak = 0;
    data = 0;
    delta = 0.0f;
    cvReleaseMat( &orig_response );
    cvReleaseMat( &sum_response );
    cvReleaseMat( &sum_response_tmp );
    cvReleaseMat( &subsample_train );
    cvReleaseMat( &subsample_test );
    cvReleaseMat( &sample_idx );
    cvReleaseMat( &missing );
    cvReleaseMat( &class_labels );
}
开发者ID:Rocky030,项目名称:opencv,代码行数:46,代码来源:gbt.cpp


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