private PointF[] ProcessFrame(Image <Bgr, Byte> image, AutomatedRodentTracker.Services.RBSK.RBSK rbsk, out double waist, out double waistArea, out double waistArea2, out double waistArea3, out double waistArea4, out PointF centroid, bool useBackground = false) { //Rectangle roi = Rectangle.Empty; //if (image.IsROISet) //{ // roi = image.ROI; // image.ROI = Rectangle.Empty; //} if (BackgroundImage != null && useBackground) { using (Image <Gray, Byte> grayImage = image.Convert <Gray, Byte>()) //using (Image<Gray, Byte> filteredImage = grayImage.SmoothMedian(rbsk.Settings.FilterLevel)) using (Image <Gray, Byte> binaryImage = grayImage.ThresholdBinary(new Gray(rbsk.Settings.BinaryThreshold), new Gray(255))) using (Image <Gray, Byte> backgroundNot = BackgroundImage.Not()) using (Image <Gray, Byte> finalImage = binaryImage.Add(backgroundNot)) using (Image <Gray, Byte> filteredImage = finalImage.SmoothMedian(rbsk.Settings.FilterLevel)) { //ImageViewer.Show(finalImage); PointF[] result = RBSKService.RBSK(filteredImage, rbsk); IBodyDetection bodyDetection = ModelResolver.Resolve <IBodyDetection>(); bodyDetection.BinaryBackground = BackgroundImage; //bodyDetection.ThresholdValue = ThresholdValue; if (result == null) { waist = -1; waistArea = -1; waistArea2 = -1; waistArea3 = -1; waistArea4 = -1; bodyDetection.GetBody(grayImage, out centroid); return(null); } bodyDetection.FindBody(grayImage, out waist, out waistArea, out waistArea2, out waistArea3, out waistArea4, out centroid); return(result); } } waist = -1; waistArea = -1; waistArea2 = -1; waistArea3 = -1; waistArea4 = -1; centroid = PointF.Empty; return(RBSKService.RBSK(image, rbsk)); }
private PointF[] ProcessFrame(Image <Bgr, Byte> image, AutomatedRodentTracker.Services.RBSK.RBSK rbsk, PointF previousPoint, double movementDelta, bool useBackground = false) { if (BackgroundImage != null && useBackground) { using (Image <Gray, Byte> grayImage = image.Convert <Gray, Byte>()) using (Image <Gray, Byte> binaryImage = grayImage.ThresholdBinary(new Gray(rbsk.Settings.BinaryThreshold), new Gray(255))) using (Image <Gray, Byte> backgroundNot = BackgroundImage.Not()) using (Image <Gray, Byte> finalImage = binaryImage.Add(backgroundNot)) using (Image <Gray, Byte> filteredImage = finalImage.SmoothMedian(rbsk.Settings.FilterLevel)) { PointF[] result = RBSKService.RBSK(filteredImage, rbsk, previousPoint, movementDelta); return(result); } } return(RBSKService.RBSK(image, rbsk, previousPoint, movementDelta)); }