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


C# Contour类代码示例

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


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

示例1: SignDetector

 public SignDetector(Image<Bgr, Byte> stopSignModel)
 {
     _detector2 = new SURFDetector(500, false);
     using (Image<Gray, Byte> redMask = GetColorPixelMask(stopSignModel))
     {
         try
         {
             _tracker2 = new Features2DTracker<float>(_detector2.DetectFeatures(redMask, null));
         }
         catch { }
     }
     _octagonStorage2 = new MemStorage();
     _octagon2 = new Contour<Point>(_octagonStorage2);
     _octagon2.PushMulti(new Point[] { 
         //hexagon
         new Point(1, 0),
         new Point(2, 0),
         new Point(3, 1),
         new Point(2, 2),
         new Point(1, 2),
         new Point(0, 1)},
         //octagon
     //new Point(1, 0),
     //new Point(2, 0),
     //new Point(3, 1),
     //new Point(3, 2),
     //new Point(2, 3),
     //new Point(1, 3),
     //new Point(0, 2),
     //new Point(0, 1)},
        Emgu.CV.CvEnum.BACK_OR_FRONT.FRONT);
 }
开发者ID:petrind,项目名称:SRTesis2,代码行数:32,代码来源:SignDetector.cs

示例2: Marker

 public Marker(Contour<Point> cInternal,
           Contour<Point> cExternal)
 {
     contourExternal = cExternal;
     contourInternal = cInternal;
     rot4Position = true;
 }
开发者ID:pawelpq,项目名称:test,代码行数:7,代码来源:Marker.cs

示例3: EContour

 public EContour(EContour c)
 {
     contour = c.getContour();
     includeContour = c.getIncludeContour();
     includeSquere = c.getIncludeSquere();
     rect = c.getRectangle();
 }
开发者ID:forkbomb,项目名称:pikto,代码行数:7,代码来源:EContour.cs

示例4: ResetContoursNavigation

        private static void ResetContoursNavigation(ref Contour<System.Drawing.Point> contours)
        {
            if (contours == null)
                return;

            //go back to the begining
            while (contours.HPrev != null)
                contours = contours.HPrev;
        }
开发者ID:aurelient,项目名称:AndreaInternship,代码行数:9,代码来源:SurfaceWindow1.xaml.cs

示例5: FindImage

        private void FindImage(Image<Gray, byte> img, List<Image<Gray, Byte>> imgList, List<Rectangle> boxList, Contour<Point> contours)
        {
            for (; contours != null; contours = contours.HNext)
            {
                contours.ApproxPoly(contours.Perimeter * 0.02, 0, contours.Storage);
                if (contours.Area > 200)
                {
                    double ratio = CvInvoke.cvMatchShapes(_octagon, contours, Emgu.CV.CvEnum.CONTOURS_MATCH_TYPE.CV_CONTOURS_MATCH_I3, 0);

                    if (ratio > 0.1) //not a good match of contour shape
                    {
                        Contour<Point> child = contours.VNext;
                        if (child != null)
                            FindImage(img, imgList, boxList, child);
                        continue;
                    }

                    Rectangle box = contours.BoundingRectangle;

                    Image<Gray, Byte> candidate;
                    using (Image<Gray, Byte> tmp = img.Copy(box))
                        candidate = tmp.Convert<Gray, byte>();

                    //set the value of pixels not in the contour region to zero
                    using (Image<Gray, Byte> mask = new Image<Gray, byte>(box.Size))
                    {
                        mask.Draw(contours, new Gray(255), new Gray(255), 0, -1, new Point(-box.X, -box.Y));

                        double mean = CvInvoke.cvAvg(candidate, mask).v0;
                        candidate._ThresholdBinary(new Gray(mean), new Gray(255.0));
                        candidate._Not();
                        mask._Not();
                        candidate.SetValue(0, mask);
                    }

                    ImageFeature<float>[] features = _detector.DetectFeatures(candidate, null);

                    int minMatchCount = 10;

                    if (features != null && features.Length >= minMatchCount)
                    {
                        Features2DTracker<float>.MatchedImageFeature[] matchedFeatures = _tracker.MatchFeature(features, 2);

                        int goodMatchCount = 0;
                        foreach (Features2DTracker<float>.MatchedImageFeature ms in matchedFeatures)
                            if (ms.SimilarFeatures[0].Distance < 0.5) goodMatchCount++;

                        if (goodMatchCount >= minMatchCount)
                        {
                            boxList.Add(box);
                            imgList.Add(candidate);
                        }
                    }
                }
            }
        }
开发者ID:etp-work,项目名称:ThePower,代码行数:56,代码来源:ImageDetector.cs

示例6: draw4ContourAndCircle

 public static void draw4ContourAndCircle(Image<Bgr, Byte> img, Contour<Point> contour)
 {
     img.Draw(contour, new Bgr(255, 0, 0), 3);
     for (int i = 0; i < contour.Total; i++)
     {
         PointF pkt = new PointF(contour[0].X,
             contour[0].Y);
         img.Draw(new CircleF(pkt, 4), new Bgr(i*50, i*50, 250), 4);
     }
 }
开发者ID:pawelpq,项目名称:test,代码行数:10,代码来源:EmguTools.cs

示例7: CreatePageForContour

 public void CreatePageForContour(Contour contour)
 {
     var page = new TabPage {
         Size = new Size(_control.Width - 8, _control.Height - 26),
         Text = string.Format("Контур {0}", contour.Index)
     };
     var grid = new ContourDataGridView{Size = new Size(page.Width, page.Height), DataSource = contour};
     page.Controls.Add(grid);
     _control.TabPages.Add(page);
 }
开发者ID:StanislavUshakov,项目名称:NumericalMethods,代码行数:10,代码来源:TabControlHelper.cs

示例8: FindContours

 public Contour<Point> FindContours(Contour<Point> contours)
 {
     for (; contours != null; contours = contours.HNext)
     {
         if (contours.Area >= ConstValue.OBJECT_MIN_AREA)
         {
             return contours;
         }
     }
     return null;
 }
开发者ID:WindAzure,项目名称:AutoCopter,代码行数:11,代码来源:AnalysisForm.cs

示例9: Window_Loaded

 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     Capture capture = new Capture(7);
     capture.Start();
     ComponentDispatcher.ThreadIdle += (o, arg) =>
         {
             var img = capture.QueryFrame();
             Emgu.CV.Contour<Bgr> con = new Contour<Bgr>(new MemStorage());
             Display.Source = BitmapSourceConvert.ToBitmapSource(img);
         };
 }
开发者ID:virrkharia,项目名称:dynamight,代码行数:11,代码来源:MainWindow.xaml.cs

示例10: BlobInfo

		public BlobInfo(Contour<Point> contour)
		{
			this.Area = contour.Area;
			this.MinAreaRect = GetMinAreaRect(contour);

			this.CameraCenter = this.MinAreaRect.center;

			if (global::Vision.CameraCalibration.Instance.IsInitialized)
			{
				this.PhysicalCenter = global::Vision.CameraCalibration.Instance.GetPhysicalPoint(this.CameraCenter);
			}
		}
开发者ID:eldb2,项目名称:robotic-tic-tac-toe-lynxmotion,代码行数:12,代码来源:BlobInfo.cs

示例11: findContours

 private static List<Rectangle> findContours(Contour<Point> contours, int minArea)
 {
     List<Rectangle> ratRect = new List<Rectangle>();
     for (; contours != null; contours = contours.HNext)
     {
         if (contours.Area > minArea)
         {
             ratRect.Add(contours.BoundingRectangle);
         }
     }
     return ratRect;
 }
开发者ID:hermanliang,项目名称:RatWalk,代码行数:12,代码来源:Form1.cs

示例12: GetNumberOfChildren

 private static int GetNumberOfChildren(Contour<Point> contours)
 {
     Contour<Point> child = contours.VNext;
     if (child == null) return 0;
     int count = 0;
     while (child != null)
     {
         count++;
         child = child.HNext;
     }
     return count;
 }
开发者ID:Rokeer,项目名称:Car_Plate_Recognition_Demo_1,代码行数:12,代码来源:Form1.cs

示例13: getContourCurvatureIndices

        public static int[] getContourCurvatureIndices(Contour<Point> contour, Point[] curvePoints)
        {
            int[] curveIndices = new int[curvePoints.Count()];

            for (int j = 0; j < curvePoints.Count(); j++)
            {
                curveIndices[j] = Array.IndexOf(contour.ToArray(), curvePoints[j]);
                Console.WriteLine(curveIndices[j] + ":" + curvePoints[j].ToString());
            }

            return curveIndices;
        }
开发者ID:faddison,项目名称:KMouse,代码行数:12,代码来源:KCurvature.cs

示例14: CamShiftTrack

      /// <summary>
      /// Use camshift to track the feature
      /// </summary>
      /// <param name="observedFeatures">The feature found from the observed image</param>
      /// <param name="initRegion">The predicted location of the model in the observed image. If not known, use MCvBox2D.Empty as default</param>
      /// <param name="priorMask">The mask that should be the same size as the observed image. Contains a priori value of the probability a match can be found. If you are not sure, pass an image fills with 1.0s</param>
      /// <returns>If a match is found, the homography projection matrix is returned. Otherwise null is returned</returns>
      public HomographyMatrix CamShiftTrack(SURFFeature[] observedFeatures, MCvBox2D initRegion, Image<Gray, Single> priorMask)
      {
         using (Image<Gray, Single> matchMask = new Image<Gray, Single>(priorMask.Size))
         {
            #region get the list of matched point on the observed image
            Single[, ,] matchMaskData = matchMask.Data;

            //Compute the matched features
            MatchedSURFFeature[] matchedFeature = _matcher.MatchFeature(observedFeatures, 2, 20);
            matchedFeature = VoteForUniqueness(matchedFeature, 0.8);

            foreach (MatchedSURFFeature f in matchedFeature)
            {
               PointF p = f.ObservedFeature.Point.pt;
               matchMaskData[(int)p.Y, (int)p.X, 0] = 1.0f / (float) f.SimilarFeatures[0].Distance;
            }
            #endregion

            Rectangle startRegion;
            if (initRegion.Equals(MCvBox2D.Empty))
               startRegion = matchMask.ROI;
            else
            {
               startRegion = PointCollection.BoundingRectangle(initRegion.GetVertices());
               if (startRegion.IntersectsWith(matchMask.ROI))
                  startRegion.Intersect(matchMask.ROI);
            }

            CvInvoke.cvMul(matchMask.Ptr, priorMask.Ptr, matchMask.Ptr, 1.0);

            MCvConnectedComp comp;
            MCvBox2D currentRegion;
            //Updates the current location
            CvInvoke.cvCamShift(matchMask.Ptr, startRegion, new MCvTermCriteria(10, 1.0e-8), out comp, out currentRegion);

            #region find the SURF features that belongs to the current Region
            MatchedSURFFeature[] featuesInCurrentRegion;
            using (MemStorage stor = new MemStorage())
            {
               Contour<System.Drawing.PointF> contour = new Contour<PointF>(stor);
               contour.PushMulti(currentRegion.GetVertices(), Emgu.CV.CvEnum.BACK_OR_FRONT.BACK);

               CvInvoke.cvBoundingRect(contour.Ptr, 1); //this is required before calling the InContour function

               featuesInCurrentRegion = Array.FindAll(matchedFeature,
                  delegate(MatchedSURFFeature f)
                  { return contour.InContour(f.ObservedFeature.Point.pt) >= 0; });
            }
            #endregion

            return GetHomographyMatrixFromMatchedFeatures(VoteForSizeAndOrientation(featuesInCurrentRegion, 1.5, 20 ));
         }
      }
开发者ID:Rustemt,项目名称:emgu_openCV,代码行数:60,代码来源:SURFTracker.cs

示例15: TraceContour

	public static Contour TraceContour( int a_iStartingPixelIndex, NeighborDirection a_eStartingDirection, int a_iContourLabel, BinarizedImage a_rBinarizedImage, int[ ] a_rLabelMap )
	{
		int iPixelIndexTrace;
		NeighborDirection eDirectionNext = a_eStartingDirection;
		FindNextPoint( a_iStartingPixelIndex, a_eStartingDirection, a_rBinarizedImage, a_rLabelMap, out iPixelIndexTrace, out eDirectionNext );
		Contour oContour = new Contour( a_iContourLabel );
		oContour.AddFirst( a_rBinarizedImage.PixelIndex2Coords( iPixelIndexTrace ) );
		int iPreviousPixelIndex = a_iStartingPixelIndex;
		int iCurrentPixelIndex = iPixelIndexTrace;
		bool bDone = ( a_iStartingPixelIndex == iPixelIndexTrace );

		// Choose a bias factor
		// The bias factor points to exterior if tracing an outer contour
		// The bias factor points to interior if tracing an inner contour
		float fOrthoBiasFactor;
		if( a_eStartingDirection == NeighborDirection.DirectionUpRight )	// inner contour
		{
			fOrthoBiasFactor = -0.2f;
		}
		else // outer contour
		{
			fOrthoBiasFactor = 0.2f;
		}
		
		while( bDone == false )
		{
			a_rLabelMap[ iCurrentPixelIndex ] = a_iContourLabel;
			NeighborDirection eDirectionSearch = (NeighborDirection) ( ( (int) eDirectionNext + 6 ) % 8 );
			int iNextPixelIndex;
			FindNextPoint( iCurrentPixelIndex, eDirectionSearch, a_rBinarizedImage, a_rLabelMap, out iNextPixelIndex, out eDirectionNext );

			iPreviousPixelIndex = iCurrentPixelIndex;
			iCurrentPixelIndex = iNextPixelIndex;
			bDone = ( iPreviousPixelIndex == a_iStartingPixelIndex && iCurrentPixelIndex == iPixelIndexTrace );

			if( bDone == false )
			{
				// Apply some bias to inner and outer contours to avoid them overlap
				// Use the orthogonal vector to direction
				NeighborDirection eOrthoBiasDirection = (NeighborDirection) ( ( (int) eDirectionNext + 6 ) % 8 ); // == direction - 2 % 8 but easier to compute (always positive)
				Vector2 f2Bias = fOrthoBiasFactor * BinarizedImage.GetDirectionVector( eOrthoBiasDirection );

				// Add bias to pixel pos
				Vector2 f2BiasedPos = f2Bias + a_rBinarizedImage.PixelIndex2Coords( iNextPixelIndex );

				// Add biased pos to contour
				oContour.AddFirst( f2BiasedPos );
			}
		}

		return oContour;	
	}
开发者ID:grifdail,项目名称:GGJ2016,代码行数:52,代码来源:Uni2DEditorContourExtractionUtils.cs


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