예제 #1
0
        public void FindBody(Image <Gray, Byte> filteredImage, out double waistLength, out double waistVolume, out double waistVolume2, out double waistVolume3, out double waistVolume4, out PointF centroid)
        {
            using (Image <Gray, Byte> binary = filteredImage.ThresholdBinary(new Gray(ThresholdValue), new Gray(255)))
                using (Image <Gray, Byte> backgroundNot = BinaryBackground.Not())
                    using (Image <Gray, Byte> finalImage = binary.Add(backgroundNot))
                        using (Image <Gray, Byte> subbed = finalImage.Not())
                        {
                            CvBlobs blobs = new CvBlobs();
                            BlobDetector.Detect(subbed, blobs);

                            CvBlob mouseBlob = null;
                            double maxArea   = -1;
                            foreach (var blob in blobs.Values)
                            {
                                if (blob.Area > maxArea)
                                {
                                    mouseBlob = blob;
                                    maxArea   = blob.Area;
                                }
                            }

                            double gapDistance = 50;
                            RBSK.Settings.GapDistance = gapDistance;

                            centroid = mouseBlob.Centroid;

                            waistLength  = -1;
                            waistVolume  = -1;
                            waistVolume2 = -1;
                            waistVolume3 = -1;
                            waistVolume4 = -1;
                        }
        }
예제 #2
0
        public void GetBody(Image <Bgr, Byte> frame, out PointF centroid)
        {
            using (Image <Gray, Byte> origGray = frame.Convert <Gray, Byte>())
                using (Image <Gray, Byte> filteredImage = origGray.SmoothMedian(13))
                    using (Image <Gray, Byte> binary = filteredImage.ThresholdBinary(new Gray(ThresholdValue), new Gray(255)))
                        using (Image <Gray, Byte> backgroundNot = BinaryBackground.Not())
                            using (Image <Gray, Byte> finalImage = binary.Add(backgroundNot))
                                using (Image <Gray, Byte> subbed = finalImage.Not())
                                {
                                    centroid = PointF.Empty;
                                    CvBlobs blobs = new CvBlobs();
                                    BlobDetector.Detect(subbed, blobs);

                                    CvBlob mouseBlob = null;
                                    double maxArea   = -1;
                                    foreach (var blob in blobs.Values)
                                    {
                                        if (blob.Area > maxArea)
                                        {
                                            mouseBlob = blob;
                                            maxArea   = blob.Area;
                                        }
                                    }

                                    if (mouseBlob != null)
                                    {
                                        centroid = mouseBlob.Centroid;
                                    }
                                }
        }
예제 #3
0
        private PointF[] ProcessFrame(Image <Bgr, Byte> image, RBSK rbsk, bool useBackground = false)
        {
            if (BinaryBackground != 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 = filteredImage.ThresholdBinary(new Gray(rbsk.Settings.BinaryThreshold), new Gray(255)))
                            using (Image <Gray, Byte> backgroundNot = BinaryBackground.Not())
                                using (Image <Gray, Byte> finalImage = binaryImage.Add(backgroundNot))
                                {
                                    PointF[] result = RBSKService.RBSK(finalImage, rbsk);
                                    return(result);
                                }
            }


            return(RBSKService.RBSK(image, rbsk));
        }