private static OpenCvSharp.CvRect FrameToPortrait(OpenCvSharp.CvRect bounds, OpenCvSharp.CvRect faceBounds) { faceBounds.X -= bounds.X; faceBounds.Y -= bounds.Y; return(faceBounds); }
public static OpenCvSharp.IplImage SubImage( this OpenCvSharp.IplImage whole, OpenCvSharp.CvRect region) { whole.SetROI(region); OpenCvSharp.IplImage part = new OpenCvSharp.IplImage(new OpenCvSharp.CvSize(region.Width, region.Height), whole.Depth, whole.NChannels); whole.Copy(part); whole.ResetROI(); return part; }
private void CompareFace( Damany.Util.DateTimeRange range, OpenCvSharp.IplImage targetImage, OpenCvSharp.CvRect rect) { try { IsRunning = true; targetImage.ROI = rect; int count = 0; var gray = targetImage.GetSub(rect).CvtToGray(); var poi = new PersonOfInterest(targetImage, gray); var repo = new PersonOfInterest[] { poi }; this._comparer.Load(repo.ToList()); //foreach (var p in portraits) //{ // if (Exit) // { // break; // } // this.view.CurrentImage = p.GetIpl().ToBitmap(); // var colorImg = p.GetIpl(); // var imgFromRepository = colorImg.GetSub(p.FaceBounds).CvtToGray(); // var result = this._comparer.CompareTo(imgFromRepository); // foreach (var repositoryCompareResult in result) // { // if (repositoryCompareResult.Similarity > Thresholds[ThresholdIndex]) // { // count++; // this.view.AddPortrait(p); // this.view.SetStatusText(string.Format("检索到 {0} 个目标", count)); // } // } //} } finally { IsRunning = false; } }
public static extern bool IsFace(IntPtr faceImg, IntPtr backImg, OpenCvSharp.CvRect SubRect);
private static bool IsStaticFrame(OpenCvSharp.CvRect rect) { return(rect.Width == 0 || rect.Height == 0); }