• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ CV_READ_SEQ_ELEM函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: cvStartAppendToSeq

/**
- FUNCTION: JoinBlob
- FUNCTIONALITY: Add's external contour to current external contour
- PARAMETERS:
	- blob: blob from which extract the added external contour
- RESULT:
	- true if no error ocurred
- RESTRICTIONS: Only external contours are added
- AUTHOR: Ricard Borràs
- CREATION DATE: 25-05-2005.
- MODIFICATION: Date. Author. Description.
*/
void CBlob::JoinBlob( CBlob *blob )
{
	CvSeqWriter writer;
	CvSeqReader reader;
	t_chainCode chainCode;

	cvStartAppendToSeq( m_externalContour.GetChainCode(), &writer );
	cvStartReadSeq( blob->GetExternalContour()->GetChainCode(), &reader );

	for (int i = 0; i < blob->GetExternalContour()->GetChainCode()->total; i++ )
	{
		CV_READ_SEQ_ELEM( chainCode, reader );
		CV_WRITE_SEQ_ELEM( chainCode, writer );
	}	
	cvEndWriteSeq( &writer );

}
开发者ID:ashokzg,项目名称:billiards,代码行数:29,代码来源:Blob.cpp


示例17: cvCreateMemStorage

/**
- FUNCTION: CBlob
- FUNCTIONALITY: Copy constructor
- PARAMETERS:
- RESULT:
- RESTRICTIONS:
- AUTHOR: Ricard Borr�
- CREATION DATE: 25-05-2005.
- MODIFICATION: Date. Author. Description.
*/
CBlob::CBlob( const CBlob &src )
{
	// 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;
	
	// 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);

	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 );
}
开发者ID:Karma-Revolutions,项目名称:icub-main,代码行数:53,代码来源:Blob.cpp


示例18: rb_codes

/*
 * call-seq:
 *   codes -> array(contain fixnum)
 *
 * Return Freeman chain codes.
 */
VALUE
rb_codes(VALUE self)
{
  CvChain *chain = CVCHAIN(self);
  CvChainPtReader reader;
  int total = chain->total;
  VALUE ary = rb_ary_new2(total);
  try {
    cvStartReadChainPoints(chain, &reader);
    for (int i = 0; i < total; ++i) {
      CV_READ_SEQ_ELEM(reader.code, (*((CvSeqReader*)&(reader))));
      rb_ary_store(ary, i, CHR2FIX(reader.code));
    }
  }
  catch (cv::Exception& e) {
    raise_cverror(e);
  }
  return ary;
}
开发者ID:afeld,项目名称:ruby-opencv,代码行数:25,代码来源:cvchain.cpp


示例19: CV_FUNCNAME

void CvGBTrees::write( CvFileStorage* fs, const char* name ) const
{
    CV_FUNCNAME( "CvGBTrees::write" );

    __BEGIN__;

    CvSeqReader reader;
    int i;
    cv::String s;

    cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_ML_GBT );

    if( !weak )
        CV_ERROR( CV_StsBadArg, "The model has not been trained yet" );

    write_params( fs );
    cvWriteReal( fs, "base_value", base_value);
    cvWriteInt( fs, "class_count", class_count);

    for ( int j=0; j < class_count; ++j )
    {
        s = cv::format("trees_%d", j);
        cvStartWriteStruct( fs, s.c_str(), CV_NODE_SEQ );

        cvStartReadSeq( weak[j], &reader );

        for( i = 0; i < weak[j]->total; i++ )
        {
            CvDTree* tree;
            CV_READ_SEQ_ELEM( tree, reader );
            cvStartWriteStruct( fs, 0, CV_NODE_MAP );
            tree->write( fs );
            cvEndWriteStruct( fs );
        }

        cvEndWriteStruct( fs );
    }

    cvEndWriteStruct( fs );

    __END__;
}
开发者ID:Rocky030,项目名称:opencv,代码行数:42,代码来源:gbt.cpp


示例20: reset


//.........这里部分代码省略.........
			// been checked for memory leaks, but a warning:
			// be careful if you call this function with alot of different
			// sized "input" images!, it does allocation every time
			// a new size is passed in....
			//inputCopy.clear();
			inputCopy.allocate( input.width, input.height );
			inputCopy = input;
		}
	}

	CvSeq* contour_list = NULL;

	contour_storage = cvCreateMemStorage( 1000 );
	storage	= cvCreateMemStorage( 1000 );

	CvContourRetrievalMode  retrieve_mode
        = (bFindHoles) ? CV_RETR_LIST : CV_RETR_EXTERNAL;
    teste = inputCopy.getCvImage();

	cvFindContours( teste, contour_storage, &contour_list,
                    sizeof(CvContour), retrieve_mode, bUseApproximation ? CV_CHAIN_APPROX_SIMPLE : CV_CHAIN_APPROX_NONE );
	CvSeq* contour_ptr = contour_list;

	nCvSeqsFound = 0;

	// put the contours from the linked list, into an array for sorting
	while( (contour_ptr != NULL) ) {
		float area = fabs( cvContourArea(contour_ptr, CV_WHOLE_SEQ) );
		if( (area > minArea) && (area < maxArea) ) {
                if (nCvSeqsFound < TOUCH_MAX_CONTOUR_LENGTH){
				cvSeqBlobs[nCvSeqsFound] = contour_ptr;	 // copy the pointer
                nCvSeqsFound++;
				}
		}
		contour_ptr = contour_ptr->h_next;
	}

	// sort the pointers based on size
	if( nCvSeqsFound > 0 ) {
		qsort( cvSeqBlobs, nCvSeqsFound, sizeof(CvSeq*), qsort_carea_compare);
	}

	// now, we have nCvSeqsFound contours, sorted by size in the array
    // cvSeqBlobs let's get the data out and into our structures that we like
	for( int i = 0; i < MIN(nConsidered, nCvSeqsFound); i++ ) {
		blobs.push_back( Blob() );
		float area = cvContourArea( cvSeqBlobs[i], CV_WHOLE_SEQ );

		cvMoments( cvSeqBlobs[i], myMoments );

		// this is if using non-angle bounding box
		CvRect rect	= cvBoundingRect( cvSeqBlobs[i], 0 );
		blobs[i].boundingRect.x      = rect.x;
		blobs[i].boundingRect.y      = rect.y;
		blobs[i].boundingRect.width  = rect.width;
		blobs[i].boundingRect.height = rect.height;

        cvCamShift(teste, rect, cvTermCriteria( CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 10, 1 ), &track_comp, &track_box);

		// this is for using angle bounding box
		CvBox2D32f box;
		box = cvMinAreaRect2( cvSeqBlobs[i] );

		blobs[i].angleBoundingRect.x	  = box.center.x;
		blobs[i].angleBoundingRect.y	  = box.center.y;
		blobs[i].angleBoundingRect.width  = box.size.height;
		blobs[i].angleBoundingRect.height = box.size.width;
		blobs[i].angle = box.angle;

		// assign other parameters
		blobs[i].area                = fabs(area);
		blobs[i].hole                = area < 0 ? true : false;
		blobs[i].length 			 = cvArcLength(cvSeqBlobs[i]);
		blobs[i].centroid.x			 = (int) (myMoments->m10 / myMoments->m00);
		blobs[i].centroid.y 		 = (int) (myMoments->m01 / myMoments->m00);
		blobs[i].lastCentroid.x 	 = (int) 0;
		blobs[i].lastCentroid.y 	 = (int) 0;

		// get the points for the blob:
		CvPoint           pt;
		CvSeqReader       reader;
		cvStartReadSeq( cvSeqBlobs[i], &reader, 0 );

    	for( int j=0; j < min(TOUCH_MAX_CONTOUR_LENGTH, cvSeqBlobs[i]->total); j++ ) {
			CV_READ_SEQ_ELEM( pt, reader );
            blobs[i].pts.push_back( ofPoint((float)pt.x, (float)pt.y) );
		}
		blobs[i].nPts = blobs[i].pts.size();

	}

    nBlobs = blobs.size();

	// Free the storage memory.
	// Warning: do this inside this function otherwise a strange memory leak
	if( contour_storage != NULL ) { cvReleaseMemStorage(&contour_storage); }
	if( storage != NULL ) { cvReleaseMemStorage(&storage); }

	return nBlobs;
}
开发者ID:Ahmedn1,项目名称:ccv-hand,代码行数:101,代码来源:ContourFinder.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ CV_RGB函数代码示例发布时间:2022-05-30
下一篇:
C++ CV_NO_GUI_ERROR函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap