private Proximity CreateProximity(string type, Device device, Point3D location, double orientation, double distance = 0.0)
 {
     return new Proximity(this, type, device.Key)
            {
                State = device.State,
                Identity = device.DeviceId,
                Location = location,
                Distance = distance,
                Orientation = orientation,
                RgbImageToDisplayRatio = device.RgbImageToDisplayRatio
            };
 }
 private void CreateDevice(BlobData blob)
 {
     var center = new Point(blob.Center.X, blob.Center.Y);
     var device = new Device(this, blob.OriginalId, "unknown")
     {
         BlobId = blob.Id,
         IsIdentified = false,
         Center = center,
         State = blob.State,
         LastBlobAngle = blob.Angle,
         Shape = blob.Polygon,
         Area = blob.Area,
     };
     AddDevice(device);
 }
Пример #3
0
        public override IData Copy()
        {
            var device = new Device(Source, OriginalBlobId, Key)
            {
                DeviceId = DeviceId,
                BlobId = BlobId,
                IsIdentified = IsIdentified,
                Center = Center,
                Angle = Angle,
                State = State,
                Shape = Shape,
                Area = Area,
                RgbImageToDisplayRatio = RgbImageToDisplayRatio
            };

            return device;
        }
 private void AddDevice(Device device)
 {
     Devices.Add(device);
 }
Пример #5
0
        private void ProcessDevice(Device device, Image<Rgb, byte> colorImage, Image<Gray, byte> grayscaleImage, int width, int height, ref Image<Rgb, byte> debugImage)
        {
            var deviceRoi = CalculateRoiFromNormalizedBounds(device.Area, colorImage);
            deviceRoi = deviceRoi.GetInflatedBy(RoiExpandFactor, colorImage.ROI);

            var imageRoi = colorImage.ROI;
            colorImage.ROI = deviceRoi;
            List<Point[]> quadrilaterals;
            var markers = GetMarkers(ref colorImage, deviceRoi, width, height, ref debugImage, out quadrilaterals);
            colorImage.ROI = imageRoi;

            var grayscaleImageRoi = grayscaleImage.ROI;
            grayscaleImage.ROI = deviceRoi;

            var i = 0;
            foreach (var marker in markers)
            {
                grayscaleImage.FillConvexPoly(quadrilaterals[i], Grays.White);

                var display = FindDisplayInImage(ref grayscaleImage, deviceRoi, width, height, marker, ref debugImage);

                if (display != null)
                {
                    if (IsRenderContent && IsFindDisplayContiuously)
                    {
                        var debugImageRoi = debugImage.ROI;
                        debugImage.ROI = deviceRoi;

                        var enclosingRectangle = display.EnclosingRectangle;
                        DrawEdge(ref debugImage, enclosingRectangle.LongEdge, Rgbs.Red);
                        DrawEdge(ref debugImage, enclosingRectangle.ShortEdge, Rgbs.Green);

                        debugImage.ROI = debugImageRoi;
                    }

                    DisplaySample displaySample;
                    if (_blobFoundInRgbImage.ContainsKey(device.BlobId))
                    {
                        displaySample = _blobFoundInRgbImage[device.BlobId];
                    }
                    else
                    {
                        displaySample = new DisplaySample();
                        _blobFoundInRgbImage.Add(device.BlobId, displaySample);
                    }

                    if (displaySample.NeedsSample())
                    {
                        displaySample.Sample(display.EnclosingRectangle);
                    }
                    else
                    {
                        _blobFoundInRgbImage.Remove(device.BlobId);
                        display.EnclosingRectangle = displaySample.GetBestSample();

                        Stage(display);
                    }

                    //Stage(display);
                }

                i++;
            }

            grayscaleImage.ROI = grayscaleImageRoi;
        }