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


C# Seq.ToArray方法代码示例

本文整理汇总了C#中Seq.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# Seq.ToArray方法的具体用法?C# Seq.ToArray怎么用?C# Seq.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Seq的用法示例。


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

示例1: HoughLineTransform

 /// <summary>
 /// Hough Line Transform, as in OpenCV (EmguCv does not wrap this function as it should be)
 /// </summary>
 /// <param name="img">Binary image</param>
 /// <param name="type">type of hough transform</param>
 /// <param name="threshold">how many votes is needed to accept line</param>
 /// <returns>Lines in theta/rho format</returns>
 public static PointF[] HoughLineTransform(Image<Gray, byte> img, Emgu.CV.CvEnum.HOUGH_TYPE type, int threshold)
 {
     using (MemStorage stor = new MemStorage())
     {
         IntPtr linePtr = CvInvoke.cvHoughLines2(img, stor.Ptr, type, 5, Math.PI / 180 * 15, threshold, 0, 0);
         Seq<PointF> seq = new Seq<PointF>(linePtr, stor);
         return seq.ToArray(); ;
     }
 }
开发者ID:rAum,项目名称:auton_net,代码行数:16,代码来源:VisionToolkit.cs

示例2: DetectKeyPoints

 /// <summary>
 /// Detect the Fast keypoints from the image
 /// </summary>
 /// <param name="image">The image to extract keypoints from</param>
 /// <returns>The array of fast keypoints</returns>
 public MKeyPoint[] DetectKeyPoints(Image<Gray, byte> image)
 {
    using (MemStorage stor = new MemStorage())
    {
       Seq<MKeyPoint> keypoints = new Seq<MKeyPoint>(stor);
       CvInvoke.CvFASTKeyPoints(image, keypoints, Threshold, NonmaxSupression);
       return keypoints.ToArray();
    }
 }
开发者ID:Rustemt,项目名称:emgu_openCV,代码行数:14,代码来源:FastDetector.cs

示例3: Detect

 /// <summary>
 /// Detect planar object from the specific image
 /// </summary>
 /// <param name="image">The image where the planar object will be detected</param>
 /// <param name="h">The homography matrix which will be updated</param>
 /// <returns>The four corners of the detected region</returns>
 public PointF[] Detect(Image<Gray, Byte> image, HomographyMatrix h)
 {
     using (MemStorage stor = new MemStorage())
      {
     Seq<PointF> corners = new Seq<PointF>(stor);
     CvPlanarObjectDetectorDetect(_ptr, image, h, corners);
     return corners.ToArray();
      }
 }
开发者ID:samuto,项目名称:UnityOpenCV,代码行数:15,代码来源:PlanarObjectDetector.cs

示例4: GetDefaultPeopleDetector

 /// <summary>
 /// Return the default people detector
 /// </summary>
 /// <returns>the default people detector</returns>
 public static float[] GetDefaultPeopleDetector()
 {
     using (MemStorage stor = new MemStorage())
      {
     Seq<float> desc = new Seq<float>(stor);
     CvHOGDescriptorPeopleDetectorCreate(desc);
     return desc.ToArray();
      }
 }
开发者ID:samuto,项目名称:UnityOpenCV,代码行数:13,代码来源:HOGDescriptor.cs

示例5: GetModelPoints

 /// <summary>
 /// Get the model points stored in this detector
 /// </summary>
 /// <returns>The model points stored in this detector</returns>
 public MKeyPoint[] GetModelPoints()
 {
     using (MemStorage stor = new MemStorage())
      {
     Seq<MKeyPoint> modelPoints = new Seq<MKeyPoint>(stor);
     CvPlanarObjectDetectorGetModelPoints(_ptr, modelPoints);
     return modelPoints.ToArray();
      }
 }
开发者ID:samuto,项目名称:UnityOpenCV,代码行数:13,代码来源:PlanarObjectDetector.cs

示例6: DetectKeyPoints

 /// <summary>
 /// Detect STAR key points from the image
 /// </summary>
 /// <param name="image">The image to extract key points from</param>
 /// <returns>The STAR key points of the image</returns>
 public MKeyPoint[] DetectKeyPoints(Image<Gray, Byte> image)
 {
     using (MemStorage stor = new MemStorage())
      {
     Seq<MKeyPoint> seq = new Seq<MKeyPoint>(stor);
     CvStarDetectorDetectKeyPoints(ref this, image, seq.Ptr);
     return seq.ToArray();
      }
 }
开发者ID:samuto,项目名称:UnityOpenCV,代码行数:14,代码来源:StarDetector.cs

示例7: DetectKeyPoints

 /// <summary>
 /// Detect the Lepetit keypoints from the image
 /// </summary>
 /// <param name="image">The image to extract Lepetit keypoints</param>
 /// <param name="maxCount">The maximum number of keypoints to be extracted</param>
 /// <param name="scaleCoords">Indicates if the coordinates should be scaled</param>
 /// <returns>The array of Lepetit keypoints</returns>
 public MKeyPoint[] DetectKeyPoints(Image<Gray, Byte> image, int maxCount, bool scaleCoords)
 {
     using (MemStorage stor = new MemStorage())
      {
     Seq<MKeyPoint> seq = new Seq<MKeyPoint>(stor);
     CvLDetectorDetectKeyPoints(ref this, image, seq.Ptr, maxCount, scaleCoords);
     return seq.ToArray();
      }
 }
开发者ID:samuto,项目名称:UnityOpenCV,代码行数:16,代码来源:LDetector.cs

示例8: DetectMultiScale

        /// <summary>
        /// Finds rectangular regions in the given image that are likely to contain objects the cascade has been trained for and returns those regions as a sequence of rectangles. 
        /// The function scans the image several times at different scales. Each time it considers overlapping regions in the image. 
        /// It may also apply some heuristics to reduce number of analyzed regions, such as Canny prunning. 
        /// After it has proceeded and collected the candidate rectangles (regions that passed the classifier cascade), it groups them and returns a sequence of average rectangles for each large enough group. 
        /// </summary>
        /// <param name="image">The image where the objects are to be detected from</param>
        /// <param name="scaleFactor">The factor by which the search window is scaled between the subsequent scans, for example, 1.1 means increasing window by 10%</param>
        /// <param name="minNeighbors">Minimum number (minus 1) of neighbor rectangles that makes up an object. All the groups of a smaller number of rectangles than min_neighbors-1 are rejected. If min_neighbors is 0, the function does not any grouping at all and returns all the detected candidate rectangles, which may be useful if the user wants to apply a customized grouping procedure</param>
        /// <param name="minSize">Minimum window size. Use Size.Empty for default, where it is set to the size of samples the classifier has been trained on (~20x20 for face detection)</param>
        /// <param name="maxSize">Maxumum window size. Use Size.Empty for default, where the parameter will be ignored.</param>
        /// <returns>The objects detected, one array per channel</returns>
        public Rectangle[] DetectMultiScale(Image<Gray, Byte> image, double scaleFactor, int minNeighbors, Size minSize, Size maxSize)
        {
            using (MemStorage stor = new MemStorage())
             {
            Seq<Rectangle> rectangles = new Seq<Rectangle>(stor);

            CvInvoke.CvCascadeClassifierDetectMultiScale(_ptr, image, rectangles, scaleFactor, minNeighbors, 0, minSize, maxSize);
            return rectangles.ToArray();
             }
        }
开发者ID:fajoy,项目名称:RTSPExample,代码行数:22,代码来源:CascadeClassifier.cs

示例9: Detect

 /// <summary>
 /// Find rectangular regions in the given image that are likely to contain objects and corresponding confidence levels
 /// </summary>
 /// <param name="image">The image to detect objects in</param>
 /// <param name="overlapThreshold">Threshold for the non-maximum suppression algorithm, Use default value of 0.5</param>
 /// <returns>Array of detected objects</returns>
 public MCvObjectDetection[] Detect(Image<Bgr, Byte> image, float overlapThreshold)
 {
     using (MemStorage stor = new MemStorage())
      {
     IntPtr seqPtr = CvInvoke.cvLatentSvmDetectObjects(image, Ptr, stor, overlapThreshold, -1);
     if (seqPtr == IntPtr.Zero)
        return new MCvObjectDetection[0];
     Seq<MCvObjectDetection> seq = new Seq<MCvObjectDetection>(seqPtr, stor);
     return seq.ToArray();
      }
 }
开发者ID:wendellinfinity,项目名称:ShoulderSurferAlert,代码行数:17,代码来源:LatentSvmDetector.cs

示例10: Detect

      /// <summary>
      /// Finds rectangular regions in the given image that are likely to contain objects the cascade has been trained for and returns those regions as a sequence of rectangles. 
      /// The function scans the image several times at different scales (see cvSetImagesForHaarClassifierCascade). Each time it considers overlapping regions in the image and applies the classifiers to the regions using cvRunHaarClassifierCascade. 
      /// It may also apply some heuristics to reduce number of analyzed regions, such as Canny prunning. 
      /// After it has proceeded and collected the candidate rectangles (regions that passed the classifier cascade), it groups them and returns a sequence of average rectangles for each large enough group. 
      /// The default parameters (scale_factor=1.1, min_neighbors=3, flags=0) are tuned for accurate yet slow object detection. 
      /// For a faster operation on real video images the settings are: scale_factor=1.2, min_neighbors=2, flags=CV_HAAR_DO_CANNY_PRUNING, min_size=&lt;minimum possible face size&gt; 
      /// (for example, ~1/4 to 1/16 of the image area in case of video conferencing). 
      /// </summary>
      /// <param name="image">The image where the objects are to be detected from</param>
      /// <param name="scaleFactor">The factor by which the search window is scaled between the subsequent scans, for example, 1.1 means increasing window by 10%</param>
      /// <param name="minNeighbors">Minimum number (minus 1) of neighbor rectangles that makes up an object. All the groups of a smaller number of rectangles than min_neighbors-1 are rejected. If min_neighbors is 0, the function does not any grouping at all and returns all the detected candidate rectangles, which may be useful if the user wants to apply a customized grouping procedure</param>
      /// <param name="flag">Mode of operation. Currently the only flag that may be specified is CV_HAAR_DO_CANNY_PRUNING. If it is set, the function uses Canny edge detector to reject some image regions that contain too few or too much edges and thus can not contain the searched object. The particular threshold values are tuned for face detection and in this case the pruning speeds up the processing.</param>
      /// <param name="minSize">Minimum window size. Use Size.Empty for default, where it is set to the size of samples the classifier has been trained on (~20x20 for face detection)</param>
      /// <param name="maxSize">Maxumum window size. Use Size.Empty for default, where the parameter will be ignored.</param>
      /// <returns>The objects detected, one array per channel</returns>
      public MCvAvgComp[] Detect(Image<Gray, Byte> image, double scaleFactor, int minNeighbors, CvEnum.HAAR_DETECTION_TYPE flag, Size minSize, Size maxSize)
      {
         using (MemStorage stor = new MemStorage())
         {
            IntPtr objects = CvInvoke.cvHaarDetectObjects(
                image.Ptr,
                Ptr,
                stor.Ptr,
                scaleFactor,
                minNeighbors,
                flag,
                minSize, 
                maxSize);

            if (objects == IntPtr.Zero)
               return new MCvAvgComp[0];

            Seq<MCvAvgComp> rects = new Seq<MCvAvgComp>(objects, stor);
            return rects.ToArray();
         }
      }
开发者ID:KaganRoman,项目名称:Eval,代码行数:37,代码来源:HaarCascade.cs

示例11: DetectMultiScale

 /// <summary>
 /// Perfroms object detection with increasing detection window.
 /// </summary>
 /// <param name="image">The image to search in</param>
 /// <param name="hitThreshold">
 /// Threshold for the distance between features and SVM classifying plane.
 /// Usually it is 0 and should be specfied in the detector coefficients (as the last free coefficient).
 /// But if the free coefficient is omitted (which is allowed), you can specify it manually here.
 ///</param>
 /// <param name="winStride">Window stride. Must be a multiple of block stride.</param>
 /// <param name="padding"></param>
 /// <param name="scale">Coefficient of the detection window increase.</param>
 /// <param name="finalThreshold">After detection some objects could be covered by many rectangles. This coefficient regulates similarity threshold. 0 means don't perform grouping. Should be an integer if not using meanshift grouping. Use 2.0 for default</param>
 /// <param name="useMeanshiftGrouping">If true, it will use meanshift grouping.</param>
 /// <returns>The regions where positives are found</returns>
 public Rectangle[] DetectMultiScale(
  Image<Bgr, Byte> image,
  double hitThreshold,
  Size winStride,
  Size padding,
  double scale,
  int finalThreshold,
  bool useMeanshiftGrouping)
 {
     using (MemStorage stor = new MemStorage())
      {
     Seq<MCvObjectDetection> seq = new Seq<MCvObjectDetection>(stor);
     CvInvoke.CvHOGDescriptorDetectMultiScale(_ptr, image, seq, hitThreshold, winStride, padding, scale, finalThreshold, useMeanshiftGrouping);
     return Array.ConvertAll(seq.ToArray(), delegate(MCvObjectDetection obj) { return obj.Rect; });
      }
 }
开发者ID:fajoy,项目名称:RTSPExample,代码行数:31,代码来源:HOGDescriptor.cs

示例12: ExtractContourAndHull

        private void ExtractContourAndHull(Image<Gray, byte> skin)
        {
            using (MemStorage storage = new MemStorage())
            {

                Contour<Point> contours = skin.FindContours(Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_LIST, storage);
                Contour<Point> biggestContour = null;

                Double Result1 = 0;
                Double Result2 = 0;
                while (contours != null)
                {
                    Result1 = contours.Area;
                    if (Result1 > Result2)
                    {
                        Result2 = Result1;
                        biggestContour = contours;
                    }
                    contours = contours.HNext;
                }

                if (biggestContour != null)
                {
                   // currentFrame.Draw(biggestContour, new Bgr(Color.Black), 2);
                    Contour<Point> currentContour = biggestContour.ApproxPoly(biggestContour.Perimeter * 0.0025, storage);
                    //currentFrame.Draw(currentContour, new Bgr(Color.Red), 2);
                    biggestContour = currentContour;

                    hull = biggestContour.GetConvexHull(Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE);
                    box = biggestContour.GetMinAreaRect();
                    PointF[] points = box.GetVertices();
                    handRect = box.MinAreaRect();
                    //int xx = (handRect.Width) / 2;
                    //int yy = (handRect.Height) / 2;
                    currentFrame.Draw(handRect, new Bgr(200, 0, 0), 1);

                    // currentFrame.Draw(new CircleF(new PointF(xx, yy), 3), new Bgr(200, 125, 75), 2);
                    Point[] ps = new Point[points.Length];
                    for (int i = 0; i < points.Length; i++)
                        ps[i] = new Point((int)points[i].X, (int)points[i].Y);

                    currentFrame.DrawPolyline(hull.ToArray(), true, new Bgr(200, 125, 75), 2);
                    currentFrame.Draw(new CircleF(new PointF(box.center.X, box.center.Y), 3), new Bgr(200, 125, 75), 2);
                   // currentFrame.Draw(new CircleF(new PointF(handRect.center.X, handRect.center.Y), 3), new Bgr(200, 125, 75), 2);

                    //ellip.MCvBox2D= CvInvoke.cvFitEllipse2(biggestContour.Ptr);
                    //currentFrame.Draw(new Ellipse(ellip.MCvBox2D), new Bgr(Color.LavenderBlush), 3);

                   // PointF center;
                    // float radius;
                    //CvInvoke.cvMinEnclosingCircle(biggestContour.Ptr, out  center, out  radius);
                    //currentFrame.Draw(new CircleF(center, radius), new Bgr(Color.Gold), 2);

                    //currentFrame.Draw(new CircleF(new PointF(ellip.MCvBox2D.center.X, ellip.MCvBox2D.center.Y), 3), new Bgr(100, 25, 55), 2);
                    //currentFrame.Draw(ellip, new Bgr(Color.DeepPink), 2);

                    //CvInvoke.cvEllipse(currentFrame, new Point((int)ellip.MCvBox2D.center.X, (int)ellip.MCvBox2D.center.Y), new System.Drawing.Size((int)ellip.MCvBox2D.size.Width, (int)ellip.MCvBox2D.size.Height), ellip.MCvBox2D.angle, 0, 360, new MCvScalar(120, 233, 88), 1, Emgu.CV.CvEnum.LINE_TYPE.EIGHT_CONNECTED, 0);
                    //currentFrame.Draw(new Ellipse(new PointF(box.center.X, box.center.Y), new SizeF(box.size.Height, box.size.Width), box.angle), new Bgr(0, 0, 0), 2);

                    filteredHull = new Seq<Point>(storage);
                    for (int i = 0; i < hull.Total; i++)
                    {
                        if (Math.Sqrt(Math.Pow(hull[i].X - hull[i + 1].X, 2) + Math.Pow(hull[i].Y - hull[i + 1].Y, 2)) > box.size.Width / 10)
                        {
                            filteredHull.Push(hull[i]);
                        }
                    }

                    defects = biggestContour.GetConvexityDefacts(storage, Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE);

                    defectArray = defects.ToArray();
                }
                            MCvMoments moment = new MCvMoments();               // a new MCvMoments object

            try
            {
                moment = biggestContour.GetMoments();           // Moments of biggestContour
            }
            catch (NullReferenceException)
            {

            }
            int fingerNum = 0;
            CvInvoke.cvMoments(biggestContour, ref moment, 0);

            double m_00 = CvInvoke.cvGetSpatialMoment(ref moment, 0, 0);
            double m_10 = CvInvoke.cvGetSpatialMoment(ref moment, 1, 0);
            double m_01 = CvInvoke.cvGetSpatialMoment(ref moment, 0, 1);

            int current_X = Convert.ToInt32(m_10 / m_00) / 10;      // X location of centre of contour
            int current_Y = Convert.ToInt32(m_01 / m_00) / 10;      // Y location of center of contour

             if (fingerNum == 1 || fingerNum == 0 || blue == 6)
             {
                 Cursor.Position = new Point(current_X * 10, current_Y * 10);
             }
             //Leave the cursor where it was and Do mouse click, if finger count >= 3

                }
        }
开发者ID:nikhilemmanuel,项目名称:Gesturised_Computer_Operation,代码行数:100,代码来源:Form1.cs

示例13: FindContourAndConvexHull

        private void FindContourAndConvexHull(Image<Gray, byte> skin, Image<Bgr, byte> imageFrame)
        {
            using (MemStorage cacheStorage = new MemStorage())
            {
                //getting the countours by simplest algorithm and list in retourn (tree isn't necessary)
                Contour<Point> contours = skin.FindContours(
                    Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE,
                    Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_LIST,
                    cacheStorage
                );

                //this variable will contain the biggest countour (if any avaiable)
                Contour<Point> largestContour = null;

                //searching for biggest countour
                Double CurrArea = 0, MaxArea = 0;
                while (contours != null)
                {
                    CurrArea = contours.Area;
                    if (CurrArea > MaxArea)
                    {
                        MaxArea = CurrArea;
                        largestContour = contours;
                    }
                    contours = contours.HNext;
                }

                if (largestContour != null)
                {
                    //drawing oryginal countour on image:
                    imageFrame.Draw(largestContour, new Bgr(Color.DarkViolet), 2);

                    //smoothing a bit the countour to make less amout of defects + draw:
                    Contour<Point> currentContour = largestContour.ApproxPoly(largestContour.Perimeter * 0.0025, cacheStorage);
                    imageFrame.Draw(currentContour, new Bgr(Color.LimeGreen), 2);
                    largestContour = currentContour;

                    //computing and drawing convex hull (smallest polygon that covers whole hand):
                    hull = largestContour.GetConvexHull(Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE);
                    imageFrame.DrawPolyline(hull.ToArray(), true, new Bgr(200, 125, 75), 2);

                    //computing smallest box (with angle), that covers the hull, and drawing without angle:
                    box = largestContour.GetMinAreaRect();
                    handRect = box.MinAreaRect();
                    imageFrame.Draw(handRect, new Bgr(200, 0, 0), 1);

                    //drawing the center of the box iwth hull:
                    imageFrame.Draw(new CircleF(new PointF(box.center.X, box.center.Y), 3), new Bgr(200, 125, 75), 2);

                    //drawing ellipse ("E") that containts most of the foun pixels:
                    if (largestContour.Count() >= 5)
                    {
                        ellip.MCvBox2D = CvInvoke.cvFitEllipse2(largestContour.Ptr);
                        imageFrame.Draw(new Ellipse(ellip.MCvBox2D), new Bgr(Color.LavenderBlush), 3);
                    }

                    //computing and drawing minimal enclosing circle, that contains whole contour:
                    PointF center;
                    float radius;
                    CvInvoke.cvMinEnclosingCircle(largestContour.Ptr, out  center, out  radius);
                    imageFrame.Draw(new CircleF(center, radius), new Bgr(Color.Gold), 2);

                    //drawing center of ellipse "E":
                    imageFrame.Draw(new CircleF(new PointF(ellip.MCvBox2D.center.X, ellip.MCvBox2D.center.Y), 3), new Bgr(100, 25, 55), 2);
                    imageFrame.Draw(ellip, new Bgr(Color.DeepPink), 2);

                    //computing and drawing ellipse ("F") that shows the direction of hand:
                    CvInvoke.cvEllipse(imageFrame,
                        new Point((int)ellip.MCvBox2D.center.X, (int)ellip.MCvBox2D.center.Y),
                        new Size((int)ellip.MCvBox2D.size.Width, (int)ellip.MCvBox2D.size.Height),
                        ellip.MCvBox2D.angle,
                        0,
                        360,
                        new MCvScalar(120, 233, 88),
                        1,
                        Emgu.CV.CvEnum.LINE_TYPE.EIGHT_CONNECTED,
                        0);

                    //drawing ellipse, that's small, but also shows the direction of hand:
                    imageFrame.Draw(
                        new Ellipse(
                            new PointF(box.center.X, box.center.Y),
                            new SizeF(box.size.Height, box.size.Width),
                            box.angle),
                        new Bgr(0, 0, 0), 2);

                    //algorithm that fiters convex hull. It saves only those points, that have distance
                    //between next point bigger than 1/10th of the box size. Small ones are removed.
                    filteredHull = new Seq<Point>(cacheStorage);
                    for (int i = 0; i < hull.Total; i++)
                    {
                        if (Math.Sqrt(Math.Pow(hull[i].X - hull[i + 1].X, 2) + Math.Pow(hull[i].Y - hull[i + 1].Y, 2)) > box.size.Width / 10)
                        {
                            filteredHull.Push(hull[i]);
                        }
                    }

                    //finding convex hull defects:
                    defects = largestContour.GetConvexityDefacts(cacheStorage, Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE);
                    defectsArr = defects.ToArray();
//.........这里部分代码省略.........
开发者ID:TBruzdzinski,项目名称:mmcv-handCTRL,代码行数:101,代码来源:Form1.cs

示例14: detectAndDrawHand

        private bool detectAndDrawHand(Contour<Point> hand)
        {
            bool realHand = false;
            double first = 0;

            Contour<Point> currentContour = hand.ApproxPoly(hand.Perimeter * 0.0025, contourStorage);

            hull = currentContour.GetConvexHull(Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE);
            box = currentContour.GetMinAreaRect();

            //Calculate the center of the hand
            PointF center = new PointF(box.center.X, box.center.Y);
            float centerX = box.center.X;
            float centerY = box.center.Y;

            //Find all defects in the contour
            defects = currentContour.GetConvexityDefacts(contourStorage, Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE);
            defectArray = defects.ToArray();

            if (defects != null)
            {
                List<double> tipDistance = new List<double>();

                for (int i = 0; i < defects.Total; i++)
                {
                    float sX = defectArray[i].StartPoint.X;
                    float sY = defectArray[i].StartPoint.Y;
                    double distance = (Math.Pow(sX - centerX, 2) + Math.Pow(sY - centerY, 2));
                    tipDistance.Add(distance);
                }

                for (int i = 0; i < tipDistance.Count(); i++)
                {
                    if (i == 0)
                    {
                        first = tipDistance.ElementAt(i);
                    }
                    else if (i > 0)
                    {
                        double difference = first - tipDistance.ElementAt(i);
                        if ((difference < 10) && (tipDistance.ElementAt(i) > -10))
                        {
                            realHand = true;
                        }
                    }
                }

                if (realHand == true)
                {
                    //Draw hand
                    drawHand(currentContour, center);

                    //Analysis hand gesture
                    string gesture = analysisHandGesture(center);
                    if ((gesture.Equals("Left Palm")) || (gesture.Equals("Left Fist")) || (gesture.Equals("Right Palm")) || (gesture.Equals("Right Fist")))
                    {
                        PointF newCenter = new PointF(centerX, centerY);
                        handMotionList.Add(skin);
                        motionPoints.Add(newCenter);
                        gestures.Add(gesture);
                        runTimes.Add(time / 1000);
                    }
                }
            }
            return realHand;
        }
开发者ID:hzhiguang,项目名称:AbuseAnalysis,代码行数:66,代码来源:Form1.cs

示例15: HandConvexHull

        //::::::::::::Method to calculate the convex hull:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

        public List<object> HandConvexHull(Image<Gray, Byte> frame, Rectangle Roi)
        {
            List<object> ListReturn = new List<object>(); 
            Image<Gray, Byte> BinaryImage;
            //PointF centerPalm; 

            BinaryImage = frame.Copy(Roi);
            
            BinaryImage = openingOperation(BinaryImage);
            BinaryImage = closeOperation(BinaryImage);
            BinaryImage.Save(path1 + numFrames.ToString() + ".png");  
            BinaryImage = binaryNiBlack(BinaryImage); 
            //naryImage = binaryThresholdNiBlack(BinaryImage);
            //

            using (MemStorage storage = new MemStorage())
            {
                Double result1 = 0;
                Double result2 = 0;
                
                Contour<System.Drawing.Point> contours = BinaryImage.FindContours(Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_LIST, storage);
                Contour<System.Drawing.Point> biggestContour = null;

                while (contours != null)
                {
                    result1 = contours.Area;
                    if (result1 > result2)
                    {
                        result2 = result1;
                      biggestContour = contours;
                    }
                    contours = contours.HNext;
                }

                if (biggestContour != null)
                {
                    Contour<System.Drawing.Point> concurrentContour = biggestContour.ApproxPoly(biggestContour.Perimeter * 0.0025, storage);
                    biggestContour = concurrentContour;

                    Hull = biggestContour.GetConvexHull(Emgu.CV.CvEnum.ORIENTATION.CV_COUNTER_CLOCKWISE);
                    defects = biggestContour.GetConvexityDefacts(storage, Emgu.CV.CvEnum.ORIENTATION.CV_COUNTER_CLOCKWISE);
                    defectsArray = defects.ToArray();

                    box = biggestContour.GetMinAreaRect();
                    points = box.GetVertices();

                    contourArea = result2;
                    contourPerimeter = biggestContour.Perimeter;
                    convexHullArea = Hull.Area;
                    convexHullPerimeter = Hull.Perimeter;

                    BinaryImage.Draw(Hull, new Gray(155), 1);
                    //ABinaryImage.Save(path1 + "ConvexHull_" + numFrames.ToString() + ".png");

                    ListReturn = GetFingersHand(BinaryImage);
                    ListReturn.Add(contourPerimeter);
                    ListReturn.Add(contourArea);
                    ListReturn.Add(convexHullPerimeter);
                    ListReturn.Add(convexHullArea);
                }
            }
            
            numFrames++; 

            return ListReturn;
        }//end HandConvexHull  
开发者ID:americamm,项目名称:SystemVersions,代码行数:68,代码来源:HandSegmentation.cs


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