如何从最小的x和y到最大的排列currentcontour.toArray

时间:2019-04-19 17:58:42

标签: c# emgucv

 for (Contour<Point> contours = grayImage.FindContours(Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_TREE, storage); contours != null; contours = contours.HNext)
                {

                    Contour<Point> currentContour = contours.ApproxPoly(contours.Perimeter * 0.05, storage);
                    if (currentContour.BoundingRectangle.Width > 100)
                    {
                        //                        CvInvoke.cvDrawContours(color, contours, new MCvScalar(255), new MCvScalar(255), -1, 2, Emgu.CV.CvEnum.LINE_TYPE.EIGHT_CONNECTED, new Point(0, 0));

                        bFirstFrameDetect = true;
                        int ContourIdx = 0;
                        foreach (Point ptBlob in currentContour.ToArray())
                        {

                            switch (ContourIdx)
                            {
                               case 0:

                                        proc.calibrPoint2.X = ptBlob.X - 5;
                                        proc.calibrPoint2.Y = ptBlob.Y - 5;

                                    break;
                                case 1:
                                    proc.calibrPoint1.X = ptBlob.X - 5;
                                    proc.calibrPoint1.Y = ptBlob.Y - 5;
                                    break;
                                case 2:
                                    proc.calibrPoint4.X = ptBlob.X - 5;
                                    proc.calibrPoint4.Y = ptBlob.Y - 5;
                                    break;
                                case 3:


                                        proc.calibrPoint3.X = ptBlob.X - 5;
                                        proc.calibrPoint3.Y = ptBlob.Y - 5;
                                        break;




                             /*   case 4:
                                    proc.calibrPoint5.X = ptBlob.X - 5;
                                    proc.calibrPoint5.Y = ptBlob.Y - 5;
                                    break;*/
                            }

                            ContourIdx++;
                        }
                    }
                }

0 个答案:

没有答案