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


C++ CvBlobs类代码示例

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


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

示例1: cvCreateImage

vector< IplImage* > Interpreter::ExtractAllSymbolBlobs(IplImage* Source)
{
	/*
	* Source: Image to be ripped from
	*/

	vector< IplImage* > AllBlobImages;

	IplImage* LabelImage = cvCreateImage(cvGetSize(Source), IPL_DEPTH_LABEL, 1);

	CvBlobs Blobs;
	unsigned int Result = cvLabel(Source, LabelImage, Blobs);


	// Crop out all the symbols, yeah
	for (CvBlobs::const_iterator it = Blobs.begin(); it != Blobs.end(); ++it)
	{
		// AllBlobImages.push_back( ConvertToSquare( CropOutBlob(Source, it->second), 300) );
		AllBlobImages.push_back( CropOutBlob(Source, it->second) );
	}

	// This next part is going to be tricky. We have to take out all _important_ blobs. There are a couple ways to do this:
	// 1. By assuming that all symbols are going to be above a certain size - this gets rid of "noise"
	// 2. By keeping all pulled regions, and later discarding any with really low confidence values - possibly slower
	// ...
	// I'll sleep on it.
	return AllBlobImages;
}
开发者ID:jammy112,项目名称:OCR-Math,代码行数:28,代码来源:Interpreter.cpp

示例2: blobsCirculares

CvBlobs blobsCirculares(CvBlobs intBlobs){
	CvBlobs *OBlobs = new CvBlobs;
	int i = 0;
	//CvBlobs::const_iterator i = OBlobs->begin();
	double difMom;
	//double excentric;
	//CvBlob *blob= new CvBlob;

	for (CvBlobs::const_iterator it=intBlobs.begin(); it!=intBlobs.end(); ++it)
		{
			
			CvBlob *blob;
				blob = (*it).second;
				*blob = *it->second;
			//if ((it->second->m10-it->second->m01 < 5) && (it->second->u02-it->second->u20 < 5) && (it->second->u11 < 5) )
			//difMom = abs((blob->n02-blob->n20)/(blob->n02));
			difMom = abs((blob->n02-blob->n20)/((blob->n20)+(blob->n02)));
			//excentric = (((blob->u20)-(blob->u02))*((blob->u20)-(blob->u02)) + 4*(blob->u11))/(blob->m00);
			if ((difMom < 0.5) && (abs(blob->n11/((blob->n20)+(blob->n02))) < 0.4) )
			//if ((excentric < 1.2) && (excentric > 0.8) )
			{
				//OBlobs->insert(it,(*it).second);
				OBlobs->insert(CvLabelBlob(blob->label,blob));
			}
			
		}
	//delete blob;
	//delete OBlobs;
	return *OBlobs;
}
开发者ID:andreig09,项目名称:Proyecto_Biomecanica,代码行数:30,代码来源:detectarBlobs.cpp

示例3: cvRenderBlobs

  void cvRenderBlobs(const IplImage *imgLabel, CvBlobs &blobs, IplImage *imgSource, IplImage *imgDest, unsigned short mode, double alpha)
  {
    CV_FUNCNAME("cvRenderBlobs");
    __CV_BEGIN__;
    {

      CV_ASSERT(imgLabel&&(imgLabel->depth==IPL_DEPTH_LABEL)&&(imgLabel->nChannels==1));
      CV_ASSERT(imgDest&&(imgDest->depth==IPL_DEPTH_8U)&&(imgDest->nChannels==3));

      Palete pal;
      if (mode&CV_BLOB_RENDER_COLOR)
      {

	unsigned int colorCount = 0;
	for (CvBlobs::const_iterator it=blobs.begin(); it!=blobs.end(); ++it)
	{
	  CvLabel label = (*it).second->label;

	  double r, g, b;

	  _HSV2RGB_((double)((colorCount*77)%360), .5, 1., r, g, b);
	  colorCount++;

	  pal[label] = CV_RGB(r, g, b);
	}
      }

      for (CvBlobs::iterator it=blobs.begin(); it!=blobs.end(); ++it)
	cvRenderBlob(imgLabel, (*it).second, imgSource, imgDest, mode, pal[(*it).second->label], alpha);
    }
    __CV_END__;
  }
开发者ID:panpeter90,项目名称:GUI,代码行数:32,代码来源:cvblob.cpp

示例4: blobs_arena

void blobs_arena(IplImage* filter,char ch)  
{
    //temp_blob to store the blobs.
    temp_blob=cvCreateImage(cvGetSize(filter),IPL_DEPTH_LABEL,1);
    //working with the blobs.
    CvBlobs blobs;
    cvLabel(filter, temp_blob, blobs);
    area=0;
    x=0;
    y=0;
    liftbox.centroid.x=10000;
    liftbox.centroid.y=10000;
    if(ch=='y')            
    cvFilterByArea(blobs, 250,650);
    else
    cvFilterByArea(blobs, 200,500);
    //cvRenderBlobs(temp_blob,blobs,input,input, CV_BLOB_RENDER_BOUNDING_BOX);
    for (CvBlobs::const_iterator it=blobs.begin(); it!=blobs.end(); ++it)
    {
           area= it->second->area;
           x= it->second->centroid.x;
           y= it->second->centroid.y;
           printf("\n arenaBlob # %d : Area= %d , Centroid=(%f,%f) \n",it->second->label, it->second->area, it->second->centroid.x, it->second->centroid.y);
           if( zoneDecider(it->second->centroid.x,it->second->centroid.y)==-1)
               if(find_Distance_pit( liftbox.centroid.x,liftbox.centroid.y) >  find_Distance_pit(x,y))
               {                 
                                 liftbox.centroid.x=x;
                                 liftbox.centroid.y=y;
                                 liftbox.color=ch;
            //cout<<"\ncentroid.x "<<liftbox.centroid.x<<"\t centroid.y "<<liftbox.centroid.y<<"\tcolor "<<liftbox.color<<"   distance  "<<liftbox.distance;
               }
     }
    cvReleaseBlobs(blobs);
    cvReleaseImage( &temp_blob );
}
开发者ID:jital94,项目名称:Techfest_final,代码行数:35,代码来源:check_grip_ADV_final_vid.cpp

示例5: detectHandGesture

void MultiCursorAppCpp::detectHandGesture(CvBlobs blobs)
{
	INT blobID = 0;
	for (CvBlobs::const_iterator it = blobs.begin(); it != blobs.end(); ++it) {
		//
		// 未実装
		//
		++blobID;
	}
}
开发者ID:tatsuya-fi,项目名称:HandGestureMultiCursor,代码行数:10,代码来源:MultiCursorAppCpp.cpp

示例6: cvFilterLabels

  void cvFilterLabels(IplImage *imgIn, IplImage *imgOut, const CvBlobs &blobs)
  {
    CV_FUNCNAME("cvFilterLabels");
    __CV_BEGIN__;
    {
      CV_ASSERT(imgIn&&(imgIn->depth==IPL_DEPTH_LABEL)&&(imgIn->nChannels==1));
      CV_ASSERT(imgOut&&(imgOut->depth==IPL_DEPTH_8U)&&(imgOut->nChannels==1));

      int stepIn = imgIn->widthStep / (imgIn->depth / 8);
      int stepOut = imgOut->widthStep / (imgOut->depth / 8);
      int imgIn_width = imgIn->width;
      int imgIn_height = imgIn->height;
      int imgIn_offset = 0;
      int imgOut_width = imgOut->width;
      int imgOut_height = imgOut->height;
      int imgOut_offset = 0;
      if(imgIn->roi)
      {
	imgIn_width = imgIn->roi->width;
	imgIn_height = imgIn->roi->height;
	imgIn_offset = imgIn->roi->xOffset + (imgIn->roi->yOffset * stepIn);
      }
      if(imgOut->roi)
      {
	imgOut_width = imgOut->roi->width;
	imgOut_height = imgOut->roi->height;
	imgOut_offset = imgOut->roi->xOffset + (imgOut->roi->yOffset * stepOut);
      }

      char *imgDataOut=imgOut->imageData + imgOut_offset;
      CvLabel *imgDataIn=(CvLabel *)imgIn->imageData + imgIn_offset;

      for (unsigned int r=0;r<(unsigned int)imgIn_height;r++,
	  imgDataIn+=stepIn,imgDataOut+=stepOut)
      {
	for (unsigned int c=0;c<(unsigned int)imgIn_width;c++)
	{
	  if (imgDataIn[c])
	  {
	    if (blobs.find(imgDataIn[c])==blobs.end()) imgDataOut[c]=0x00;
	    else imgDataOut[c]=(char)0xff;
	  }
	  else
	    imgDataOut[c]=0x00;
	}
      }
    }
    __CV_END__;
  }
开发者ID:lukaijovana,项目名称:Parking_slobodna_mesta_project,代码行数:49,代码来源:cvlabel.cpp

示例7: cvFilterByLabel

  void cvFilterByLabel(CvBlobs &blobs, CvLabel label)
  {
    CvBlobs::iterator it=blobs.begin();
    while(it!=blobs.end())
    {
      CvBlob *blob=(*it).second;
      if (blob->label!=label)
      {
	delete blob;
	CvBlobs::iterator tmp=it;
	++it;
	blobs.erase(tmp);
      }
      else
	++it;
    }
  }
开发者ID:panpeter90,项目名称:GUI,代码行数:17,代码来源:cvblob.cpp

示例8: ubicarBlob

//ubica un blob dado en otro conjunto de blobs.
//(POR AHORA ENCUENTRA SOLO EL MAS CERCANO, la idea es hacerlo más 
//robusto, por ejemplo con el sistema de puntajes.)
CvBlob ubicarBlob(CvBlob blobanterior, CvBlobs blobs){ 
	
	//inicializar objetos
	CvPoint centroideanterior;
	centroideanterior.x = blobanterior.centroid.x;
	centroideanterior.y = blobanterior.centroid.y;
	CvPoint centroide;
	CvBlob actual;
	
	//Lista de <label,blob>										//Probablemente esto sea innecesario, pero no pude recorrer los CvBlobs
	vector< pair<CvLabel, CvBlob*> > blobList;
    copy(blobs.begin(), blobs.end(), back_inserter(blobList));

	actual = *blobList[0].second;
	double distancia;
	double distanciaNueva;
	distancia = Distance2(centroideanterior.x,centroideanterior.y,actual.centroid.x,actual.centroid.y);
	int tamanio = blobList.size();

	//recorre todos los blobs y se queda con el que tiene el centroide más cerca
	for (int i = 0; i < tamanio; i++)
	{
		centroide.x = (*blobList[i].second).centroid.x;
		centroide.y = (*blobList[i].second).centroid.y;
		distanciaNueva = Distance2(centroideanterior.x,centroideanterior.y,centroide.x,centroide.y);
		if (distanciaNueva < distancia )
		{
			actual = (*blobList[i].second);
			distancia = distanciaNueva;
		}
	}

	//supongo que de un cuadro a otro el blob no se mueve más de 100 pixeles
	//Esto habría que acomodarlo (cuando estén implementadas las otras condiciones) para que
	//en vez de solo la distancia, evalúe si encontró el blob o el mismo desapareció.
	if (distancia < 100)
	{
		return actual;
	}else
	{
		return blobanterior;
	}
	

}
开发者ID:andreig09,项目名称:Proyecto_Biomecanica,代码行数:48,代码来源:detectarBlobs.cpp

示例9: cvGreaterBlob

CvLabel cvGreaterBlob(const CvBlobs &blobs)
{
    CvLabel label=0;
    unsigned int maxArea=0;

    for (CvBlobs::const_iterator it=blobs.begin(); it!=blobs.end(); ++it)
    {
        CvBlob *blob=(*it).second;
        //if ((!blob->_parent)&&(blob->area>maxArea))
        if (blob->area>maxArea)
        {
            label=blob->label;
            maxArea=blob->area;
        }
    }

    return label;
}
开发者ID:walchko,项目名称:tennis_ball,代码行数:18,代码来源:cvblob.cpp

示例10: cvLargestBlob

  CvLabel cvLargestBlob(const CvBlobs &blobs)
  {
    CvLabel label=0;
    unsigned int maxArea=0;

    for (CvBlobs::const_iterator it=blobs.begin();it!=blobs.end();++it)
    {
      CvBlob *blob=(*it).second;

      if (blob->area > maxArea)
      {
		label=blob->label;
		maxArea=blob->area;
      }
    }

    return label;
  }
开发者ID:panpeter90,项目名称:GUI,代码行数:18,代码来源:cvblob.cpp

示例11: cvFilterByArea

  void cvFilterByArea(CvBlobs &blobs, unsigned int minArea, unsigned int maxArea)
  {
    CvBlobs::iterator it=blobs.begin();
    while(it!=blobs.end())
    {
      CvBlob *blob=(*it).second;
      if ((blob->area<minArea)||(blob->area>maxArea))
      {
	cvReleaseBlob(blob);

	CvBlobs::iterator tmp=it;
	++it;
	blobs.erase(tmp);
      }
      else
	++it;
    }
  }
开发者ID:panpeter90,项目名称:GUI,代码行数:18,代码来源:cvblob.cpp

示例12: blobs

//general blobs in arena and bot        
void blobs(IplImage* filter,char ch)  
{
    //temp_blob to store the blobs.
    temp_blob=cvCreateImage(cvGetSize(filter),IPL_DEPTH_LABEL,1);
    //working with the blobs.
    CvBlobs blobs;
    cvLabel(filter, temp_blob, blobs);
    area=0;
    x=0;
    y=0;
    //cvRenderBlobs(temp_blob,blobs,input,input, CV_BLOB_RENDER_BOUNDING_BOX);
    if(ch=='p' ||ch== 'o')
    {
        cvFilterByArea(blobs, 400,3000);
        for (CvBlobs::const_iterator it=blobs.begin(); it!=blobs.end(); ++it)
        {
              area= it->second->area;
               x= it->second->centroid.x;
               y= it->second->centroid.y;
               //printf("\n Blob # %d : Area= %d , Centroid=(%f,%f) (x,y):(%d,%d)",it->second->label, it->second->area, it->second->centroid.x, it->second->centroid.y,x,y);
        }
     }
    
    else
    {
        cvFilterByArea(blobs, 100,700);
        for (CvBlobs::const_iterator it=blobs.begin(); it!=blobs.end(); ++it)
        {
              area= it->second->area;
               x= it->second->centroid.x;
               y= it->second->centroid.y;
               if(zoneDecider(it->second->centroid.x,it->second->centroid.y)==1)
               {                 
                    puzzle[k].centroid.x=x;
                    puzzle[k].centroid.y=y;
                    puzzle[k].color=ch;
                    k++;
                printf("\n Blob # %d : Area= %d , Centroid=(%f,%f) \n",it->second->label, it->second->area, it->second->centroid.x, it->second->centroid.y);
                }
        }
     }
    cvReleaseBlobs(blobs);
    cvReleaseImage( &temp_blob );
}
开发者ID:jital94,项目名称:Techfest_final,代码行数:45,代码来源:check_grip_ADV_final_vid.cpp

示例13: main

int main(){
	Mat frame;
	Mat frame_small;
	Mat frame_hsv;

	VideoCapture cap;
	cap.open(0);

	namedWindow("Captured Frame", CV_WINDOW_AUTOSIZE);
	namedWindow("Detected Blobs", CV_WINDOW_AUTOSIZE);

	while (1){
		cap >> frame;
		resize(frame,frame_small,Size(),1,1,CV_INTER_AREA);
		cvtColor(frame_small, frame_small, CV_BGR2HSV);
		inRange(frame_small,Scalar(YELLOW_HUE_LOWER,50,50),Scalar(YELLOW_HUE_UPPER,255,255),frame_hsv);
		//frame_hsv = 255-frame_hsv;
		//resize(image_hsv,image_hsv,Size(),4,4,CV_INTER_AREA);
		Mat frame_bw = frame_hsv>128;
		IplImage image_bw = frame_bw;
		IplImage image_small = frame_small;
		//cvThreshold(&hsv_1, &hsv_1, 100, 200, CV_THRESH_BINARY);
		IplImage *labelImg = cvCreateImage(cvGetSize(&image_bw), IPL_DEPTH_LABEL, 1);
		CvBlobs blobs;
		unsigned int result = cvLabel(&image_bw, labelImg, blobs);
		for (CvBlobs::const_iterator it=blobs.begin(); it!=blobs.end(); ++it)
		{
  			// cout << "Blob #" << it->second->label << ": Area=" << it->second->area << ", Centroid=(" << it->second->centroid.x << ", " << it->second->centroid.y << ")" << endl;
  			x[it->second->label] = 0.8*x[it->second->label]+0.2*it->second->centroid.x;
  			y[it->second->label] = 0.8*x[it->second->label]+0.2*it->second->centroid.y;
		}
		cvRenderBlobs(labelImg, blobs, &image_small, &image_small);
		cvShowImage("Detected Blobs", &image_small);
		imshow("Captured Frame", frame);
		if(waitKey(10)>=0) break;
		cout << "(x,y) => (" << x[1] << "," << y[1] <<"); (x,y) => (" << x[2] << "," << y[2] << ")\n";
	}
	return 0;
}
开发者ID:srmanikandasriram,项目名称:multi-agent-robot-test-platform,代码行数:39,代码来源:pattern_tracking.cpp

示例14: main

int main()
{
  IplImage *img = cvLoadImage("test.png", 1);

  cvSetImageROI(img, cvRect(100, 100, 800, 500));

  IplImage *grey = cvCreateImage(cvGetSize(img), IPL_DEPTH_8U, 1);
  cvCvtColor(img, grey, CV_BGR2GRAY);
  cvThreshold(grey, grey, 100, 255, CV_THRESH_BINARY);

  IplImage *labelImg = cvCreateImage(cvGetSize(grey),IPL_DEPTH_LABEL,1);

  CvBlobs blobs;
  unsigned int result = cvLabel(grey, labelImg, blobs);

  IplImage *imgOut = cvCreateImage(cvGetSize(img), IPL_DEPTH_8U, 3); cvZero(imgOut);
  cvRenderBlobs(labelImg, blobs, img, imgOut);

  //unsigned int i = 0;

  // Render contours:
  for (CvBlobs::const_iterator it=blobs.begin(); it!=blobs.end(); ++it)
  {
    //cvRenderBlob(labelImg, (*it).second, img, imgOut);
    
    CvScalar meanColor = cvBlobMeanColor((*it).second, labelImg, img);
    cout << "Mean color: r=" << (unsigned int)meanColor.val[0] << ", g=" << (unsigned int)meanColor.val[1] << ", b=" << (unsigned int)meanColor.val[2] << endl;

    CvContourPolygon *polygon = cvConvertChainCodesToPolygon(&(*it).second->contour);

    CvContourPolygon *sPolygon = cvSimplifyPolygon(polygon, 10.);
    CvContourPolygon *cPolygon = cvPolygonContourConvexHull(sPolygon);

    cvRenderContourChainCode(&(*it).second->contour, imgOut);
    cvRenderContourPolygon(sPolygon, imgOut, CV_RGB(0, 0, 255));
    cvRenderContourPolygon(cPolygon, imgOut, CV_RGB(0, 255, 0));

    delete cPolygon;
    delete sPolygon;
    delete polygon;

    // Render internal contours:
    for (CvContoursChainCode::const_iterator jt=(*it).second->internalContours.begin(); jt!=(*it).second->internalContours.end(); ++jt)
      cvRenderContourChainCode((*jt), imgOut);

    //stringstream filename;
    //filename << "blob_" << setw(2) << setfill('0') << i++ << ".png";
    //cvSaveImageBlob(filename.str().c_str(), imgOut, (*it).second);
  }

  cvNamedWindow("test", 1);
  cvShowImage("test", imgOut);
  //cvShowImage("grey", grey);
  cvWaitKey(0);
  cvDestroyWindow("test");

  cvReleaseImage(&imgOut);
  cvReleaseImage(&grey);
  cvReleaseImage(&labelImg);
  cvReleaseImage(&img);

  cvReleaseBlobs(blobs);

  return 0;
}
开发者ID:553406268,项目名称:cvblob,代码行数:65,代码来源:test.cpp

示例15: main

int main()
{
	//INITIALIZE CAMERA
	HIDS hCam = 1;
	initializeCam(hCam);
	setImgMem(hCam);

	//Windows
	cvNamedWindow("Live",CV_WINDOW_AUTOSIZE);
	cvNamedWindow("Threshed", CV_WINDOW_AUTOSIZE);

	while(1)
		{

			//Image Variables
			IplImage* frame=cvCreateImage(cvSize(752, 480), 8, 3);//fisheye image
			IplImage* img_hsv=cvCreateImage(cvSize(752, 480), 8, 3);//Image in HSV color space
			IplImage* threshy = cvCreateImage(cvSize(752, 480), 8, 1);
			IplImage* labelImg=cvCreateImage(cvSize(752, 480),IPL_DEPTH_LABEL,1);//Image Variable for blobs

			CvBlobs blobs;

			int xu, yu;		//coordinates of undistorted image
			int xd, yd;		//coordinates in distorted image

			//Getting the current frame
			getFrame(hCam, frame);
			//If failed to get break the loop
			if(!frame)
				break;

			cvCvtColor(frame,img_hsv,CV_BGR2HSV);
			//Thresholding the frame for yellow
			cvInRangeS(img_hsv, cvScalar(20, 100, 20), cvScalar(30, 255, 255), threshy);
			// cvInRangeS(img_hsv, cvScalar(0,0,0), cvScalar(16,255,255), threshy);
			// cvInRangeS(img_hsv, cvScalar(0,0,0),cvScalar(16,255,255), threshy);//cvScalar(0, 120, 40), cvScalar(255, 255, 255)
			//Filtering the frame
			cvSmooth(threshy,threshy,CV_MEDIAN,7,7);
			//Finding the blobs
			unsigned int result=cvLabel(threshy,labelImg,blobs);
			//Filtering the blobs
			cvFilterByArea(blobs,100,10000);
			//Rendering the blobs
			cvRenderBlobs(labelImg,blobs,frame,frame);

			for (CvBlobs::const_iterator it=blobs.begin(); it!=blobs.end(); ++it)
			{
				xd =(it->second->maxx + it->second->minx )/2;
				// yd =(it->second->maxy + it->second->miny )/2;
				yd =(it->second->maxy);

				cvCircle(frame,cvPoint(xd,yd),2,CV_RGB(255,0,0),3);
				
				xd = xd - 752/2;
				yd = -yd + 480/2;

				cout<<"\nnon-linear coords: xd="<<xd<<"     yd="<<yd<<endl;

				getLinearCoords(xd, yd, &xu, &yu);
				cout<<"\nlinear coords: x="<<xu<<"     y="<<yu<<endl;			
				// getPt(xu, yu,current.angle,current.focal,current.pix2cmy,current.s_view_compensation);
			}
			//Showing the images
			cvShowImage("Live",frame);
			cvShowImage("Threshed",threshy);

			char c=cvWaitKey(10);

			if(int(c) == 27)
				break;

			cvReleaseImage(&frame);
			cvReleaseImage(&threshy);
			cvReleaseImage(&img_hsv);
			cvReleaseImage(&labelImg);
		}

	//Cleanup
	cvDestroyAllWindows();
	exitCam(hCam);
	return 0;
}
开发者ID:p-kar,项目名称:vision,代码行数:82,代码来源:obstacle_detection.cpp


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