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


C# Emgu.GetSubRect方法代码示例

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


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

示例1: FindFaces

        public List<FaceScored> FindFaces(Emgu.CV.Image<Emgu.CV.Structure.Bgr, byte> image, CascadeClassifier cascadeClassifierFace, CascadeClassifier cascadeClassifierEye)
        {
            List<FaceScored> currentFaces = new List<FaceScored>();
            using (Image<Gray, Byte> gray = image.Convert<Gray, Byte>())
            {
            gray._EqualizeHist();
            Size minFaceSize = new Size(minSizeFace , minSizeFace );
            Size maxFaceSize =  new Size(maxSizeFace , maxSizeFace );
            Size minEyeSize = new Size(minSizeEye , minSizeEye );
            Size maxEyeSize =  new Size(maxSizeEye , maxSizeEye );
            Rectangle[] facesDetected = cascadeClassifierFace.DetectMultiScale(gray, scaleFace , neighborsFace , minFaceSize,maxFaceSize);

            foreach (Rectangle f in facesDetected)
            {
                if (f.Width<35)
                    break;
                gray.ROI = f;

                Rectangle[] eyesDetected = cascadeClassifierEye.DetectMultiScale(gray, scaleEye, neighborsEye, minEyeSize, maxEyeSize);
                if (eyesDetected.Count() >0){
                    FaceScored faceModel = new FaceScored();
                    faceModel.FaceImage = gray.Bitmap;
                    faceModel.FaceImageFullColr = image.GetSubRect(f).Bitmap;
                    faceModel.Height = faceModel.FaceImage.Height;
                    faceModel.Width = faceModel.FaceImage.Width;
                    faceModel.EyesCount = eyesDetected.Count();

                    Gray avgf = new Gray();
                    MCvScalar avstd = new MCvScalar();
                    gray.AvgSdv(out avgf, out avstd);
                    faceModel.StdDev = avstd.V0;

                    currentFaces.Add(faceModel);
                    if(currentFaces.Count%5==0)
                        Console.WriteLine("FaceDetect Add every 5 faceModel" + faceModel.Width);
                    break;
                }
                gray.ROI = Rectangle.Empty;
                }
            }
            return currentFaces;
        }
开发者ID:kmacpher67,项目名称:PlantLifeAnimation,代码行数:42,代码来源:FaceDetection.cs

示例2: FindPattern

 /// <summary>
 /// Find pattern in image region
 /// </summary>
 /// <param name="img">Image to find pattern in</param>
 /// <param name="roi">Region of interest</param>
 /// <param name="image_points">Image points relative to original image</param>
 /// <returns></returns>
 public bool FindPattern(Emgu.CV.Image<Gray, byte> img, Rectangle roi, out PointF[] image_points) {
   try {
     if (!roi.IsEmpty) {
       Emgu.CV.Image<Gray, byte> selected = img.GetSubRect(roi); // Shares memory with original image
       bool found = this.FindPattern(selected, out image_points);
       // Transform points back to original image coordinates
       PointF origin = roi.Location;
       for (int i = 0; i < image_points.Length; i++) {
         image_points[i] = new PointF(image_points[i].X + origin.X, image_points[i].Y + origin.Y);
       }
       return found;
     } else {
       image_points = new PointF[0];
       return false;
     }
   } catch (Emgu.CV.CvException) {
     image_points = new PointF[0];
     return false;
   }
 }
开发者ID:guozanhua,项目名称:parsley,代码行数:27,代码来源:CalibrationPattern.cs


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