本文整理汇总了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;
}
示例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;
}
}