/// <summary>
        /// Handle image size change events
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Image_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            float cameraAspectRatio = (float)m_frameWidth / m_frameHeight;
            float uiAspectRatio     = (float)(m_image.ActualWidth / m_image.ActualHeight);

            if (uiAspectRatio > cameraAspectRatio)
            {
                m_canvas.Height = m_image.ActualHeight;
                m_canvas.Width  = m_image.ActualHeight * cameraAspectRatio;
            }
            else
            {
                m_canvas.Width  = m_image.ActualWidth;
                m_canvas.Height = m_image.ActualWidth / cameraAspectRatio;
            }

            m_inputQuadRenderer.Update(m_inputQuadCorners);
        }
        /// <summary>
        /// ImageRectifierControl constructor
        /// </summary>
        /// <param name="binding"></param>
        public ImageRectifierControl(ISkillBinding binding) : base(binding)
        {
            // Update the view of the initial binding values
            m_ImageRectifierBindingFeatureValues = ExtractBindingValues(binding);
            m_interactiveControl = new ImageRectifierInteractiveControl();
            m_interactiveControl.InterpolationTypeChanged += ImageRectifierInteractiveControl_InterpolationTypeChanged;

            m_imageGrid.Children.Add(m_canvas);
            m_image.SetValue(Canvas.ZIndexProperty, -1);
            m_image.SizeChanged += Image_SizeChanged;

            // Add InputQuad control
            m_inputQuadRenderer = new InteractiveQuadRenderer(ref m_canvas);
            m_inputQuadRenderer.CornersChanged         += InteractiveQuadRenderer_CornersChanged;
            m_inputQuadRenderer.CornersChangeCompleted += InteractiveQuadRenderer_CornersChangeCompleted;
            m_inputQuadRenderer.Update(m_ImageRectifierBindingFeatureValues.InputQuad);

            Children.Add(m_interactiveControl);
            m_interactiveControl.UpdateDisplayedInputValues(m_ImageRectifierBindingFeatureValues);
            m_interactiveControl.UpdateInterpolationType(m_ImageRectifierBindingFeatureValues.InterpolationType);
        }
예제 #3
0
        /// <summary>
        ///  CurvedEdgesDetectorControl constructor
        /// </summary>
        /// <param name="binding"></param>
        public CurvedEdgesDetectorControl(ISkillBinding binding) : base(binding)
        {
            // Update the view of the initial binding values
            m_interactiveControl = new CurvedEdgesDetectorSkillInteractiveControl();

            m_imageGrid.Children.Add(m_canvas);
            m_image.SetValue(Canvas.ZIndexProperty, -1);
            m_image.SizeChanged += Image_SizeChanged;

            // Add line result control
            m_linesResultRenderer = new PolylineRenderer(ref m_canvas);

            m_linesResultRenderer.IsVisible = false;

            Children.Add(m_interactiveControl);
            m_interactiveControl.UpdateBaseQuadCorners(m_inputQuadCorners);

            // Add control to manipulate InputQuad
            m_inputQuadRenderer           = new InteractiveQuadRenderer(ref m_canvas);
            m_inputQuadRenderer.IsVisible = true;
            m_inputQuadRenderer.Update(m_inputQuadCorners);
            m_inputQuadRenderer.CornersChanged         += InteractiveQuadRenderer_CornersChanged;
            m_inputQuadRenderer.CornersChangeCompleted += InteractiveQuadRenderer_CornersChangeCompleted;
        }