private SceneRect GetRect(CaptureSource model)
        {
            SceneRect rect = null;

            if (model.W > 0 && model.H > 0)
            {
                var ratio = (double)model.W / (double)model.H;

                var baseExtent = 0.5;
                var baseRatio  = 16.0 / 9.0;

                if (ratio > baseRatio)
                {
                    rect = new SceneRect {
                        W = baseExtent, H = baseExtent * baseRatio / ratio
                    }
                }
                ;
                else
                {
                    rect = new SceneRect {
                        W = baseExtent * ratio / baseRatio, H = baseExtent
                    }
                };
            }
            return(rect);
        }
Example #2
0
        protected Box(SerializationInfo pInfo, StreamingContext pContext)
            : base(pInfo, pContext)
        {
            // for version evaluation while deserializing
            int pSerVersion = pInfo.GetInt32("m_SerVersion");

            if (m_SerVersion >= 1)
            {
                m_DepthMean = pInfo.GetDouble("m_DepthMean");
                m_SceneItem = new SceneRect();
            }

            if (m_SerVersion >= 2)
            {
                m_MatchPercentageOffset = pInfo.GetDouble("m_MatchPercentageOffset");
            }

            if (m_SerVersion >= 3)
            {
                m_LowerThreshold = pInfo.GetInt32("m_LowerThreshold");
                m_UpperThreshold = pInfo.GetInt32("m_UpperThreshold");
            }

            updateScene();
        }
Example #3
0
        public Box()
            : base()
        {
            m_SceneItem = new SceneRect();

            updateScene();
        }
Example #4
0
        public void UpdateFromModel()
        {
            if (!Equals(Rect.Value, Model.Rect))
            {
                Rect.SilentValue = Model.Rect;
            }

            Maximize.CanExecute.Value = !Equals(Model.Rect, SceneRect.Full());
            Zoom.SetPtz(Model.Ptz, Model.ZoomBehavior, Model.Source?.Device != null);
        }
Example #5
0
        protected ObjectDetectionZone(SerializationInfo pInfo, StreamingContext pContext)
            : base(pInfo, pContext)
        {
            // for version evaluation while deserializing
            int pSerVersion = pInfo.GetInt32("m_SerVersion");

            m_Depth     = pInfo.GetInt32("m_Depth");
            m_DepthMean = pInfo.GetDouble("m_DepthMean");
            m_SceneItem = new SceneRect();
            updateScene();
        }
Example #6
0
        private void UpdateOrCreateItem(string id, byte[] data)
        {
            var source = new SceneItemSource {
                Image = new SceneItemSourceImage {
                    ResourceId = id
                }
            };

            if (Editing)
            {
                _editedItem.Source = source;
            }
            else
            {
                var size = _model.ImageHelper.GetSize(data);

                SceneRect rect = null;
                if (size.width > 0 && size.height > 0)
                {
                    var ratio = (double)size.width / (double)size.height;

                    var baseExtent = 0.5;
                    var baseRatio  = 16.0 / 9.0;

                    if (ratio > baseRatio)
                    {
                        rect = new SceneRect {
                            W = baseExtent, H = baseExtent * baseRatio / ratio
                        }
                    }
                    ;
                    else
                    {
                        rect = new SceneRect {
                            W = baseExtent * ratio / baseRatio, H = baseExtent
                        }
                    };
                }

                _model.AddSourceToScene(source, false, rect);
            }
        }
Example #7
0
 public ObjectDetectionZone(int pId)
     : base(pId)
 {
     m_SceneItem = new SceneRect();
     updateScene();
 }
Example #8
0
 public static void SetRect(DependencyObject element, SceneRect value) => element.SetValue(RectProperty, value);
 private void OnDragStarted(object sender, DragStartedEventArgs e)
 {
     _startDrag = Mouse.GetPosition(_parent);
     _startRect = _parent.Rect;
 }
Example #10
0
 public Box(int pId)
     : base(pId)
 {
     m_SceneItem = new SceneRect();
     updateScene();
 }