Пример #1
0
        private void EndWalkthrough()
        {
            LastStateAction?.Invoke();

            imageBox.SelectNone();

            if (anchorPlaceholderControls.TrueForAll(x => x.IsInitialized) && testPointPlaceholderControl.IsInitialized)
            {
                List <Template.AnchorAlignmentMethod.Anchor> anchors = new List <Template.AnchorAlignmentMethod.Anchor>();
                for (int i = 0; i < anchorPlaceholderControls.Count; i++)
                {
                    anchors.Add(anchorPlaceholderControls[i].GetAnchor);
                }
                Template.AnchorAlignmentMethod.Anchor testPointAnchor = testPointPlaceholderControl.GetAnchor;

                if (referenceAnchorAlignmentMethod != null)
                {
                    referenceAnchorAlignmentMethod.SetAnchors(anchors);
                    referenceAnchorAlignmentMethod.SetTestAnchor(testPointAnchor);

                    OnConfigurationFinishedEvent?.Invoke(referenceAnchorAlignmentMethod);
                }
                else
                {
                    Template.AnchorAlignmentMethod anchorAlignmentMethod = new Template.AnchorAlignmentMethod(anchors, testPointAnchor, templateImage.Size, pipelineIndex, methodName, selectedSize, selectedScale);
                    OnConfigurationFinishedEvent?.Invoke(anchorAlignmentMethod);
                }
                ValidateState();
            }
            else
            {
                InvalidateState();
            }
        }
Пример #2
0
        private void SetupForConfigured(Template.AnchorAlignmentMethod anchorAlignmentMethod, Bitmap templateImage)
        {
            referenceAnchorAlignmentMethod = anchorAlignmentMethod;

            MinimumSize = new Size(500, 600);

            MainLayoutPanel.RowStyles[1].SizeType = SizeType.Absolute;
            MainLayoutPanel.RowStyles[1].Height   = 58;

            statePanelsPanel.Controls.Remove(SizeValueStatePanel);

            for (int i = 0; i < configureStatesPanel.RowCount; i++)
            {
                configureStatesPanel.RowStyles[i].SizeType = SizeType.Percent;
                configureStatesPanel.RowStyles[i].Height   = i == 0 ? 100 : i == 1 ? 0 : i == 2 ? 0 : i == 3 ? 0 : 0;
            }

            var list = EnumHelper.ToList(typeof(ConfigurationState));

            list.RemoveAt(0);
            selectStateComboBox.DataSource    = list;
            selectStateComboBox.DisplayMember = "Value";
            selectStateComboBox.ValueMember   = "Key";

            if (!curConfigureStatePanel.Controls.Contains(statePanelsPanel))
            {
                curConfigureStatePanel.Controls.Add(statePanelsPanel, 1, 0);
            }
            statePanelsPanel.Dock    = DockStyle.Fill;
            statePanelsPanel.Visible = true;

            configureStatesPanel.Visible = true;

            resizedImage      = new Image <Gray, byte>(templateImage).Resize(anchorAlignmentMethod.GetDownscaleSize.Width, anchorAlignmentMethod.GetDownscaleSize.Height, Emgu.CV.CvEnum.Inter.Cubic);
            TemplateImage     = templateImage == null ? TemplateImage : resizedImage;
            templateImageCopy = TemplateImage.Clone();
            imageBox.Image    = TemplateImage.Bitmap;

            var refAnchors = anchorAlignmentMethod.GetAnchors;

            for (int i = 0; i < refAnchors.Count; i++)
            {
                AnchorPlaceholderControl anchorPlaceholder = anchorPlaceholderControls[i];
                anchorPlaceholder.Initialize(refAnchors[i].GetAnchorRegion, (Mat)refAnchors[i].GetAnchorImage, DeleteAnchorAction);
                anchorPlaceholder.IsCurrent = false;
                anchors.Add(anchorPlaceholder.GetAnchor);

                if (!anchorPlaceholderControls.Exists(x => x.IsInitialized == false))
                {
                    continue;
                }

                curAnchorIndex = anchorPlaceholderControls.Find(x => x.IsInitialized == false).Index;
                anchorPlaceholderControls[curAnchorIndex].IsCurrent = true;
            }
            testPointPlaceholderControl.Initialize(anchorAlignmentMethod.GetTestAnchor.GetAnchorRegion, (Mat)anchorAlignmentMethod.GetTestAnchor.GetAnchorImage, DeleteAnchorAction);
        }
Пример #3
0
        public AnchorAlignmentMethodForm(Template.AnchorAlignmentMethod anchorAlignmentMethod, Mat templateImage)
        {
            InitializeComponent();

            Awake();

            this.templateImage = templateImage;
            var btm = templateImage.Bitmap;

            pipelineIndex  = anchorAlignmentMethod.PipelineIndex;
            methodName     = anchorAlignmentMethod.MethodName;
            imageBox.Image = btm;

            Initialize(anchorAlignmentMethod, btm);
        }
Пример #4
0
        private TabPageAdv CreateAlignmentMethodTabPage(Template.AlignmentMethod alignmentMethod)
        {
            TabPageAdv result = null;

            switch (alignmentMethod.GetAlignmentMethodType)
            {
            case Template.AlignmentMethodType.Anchors:
                Template.AnchorAlignmentMethod anchorAlignmentMethod = (Template.AnchorAlignmentMethod)alignmentMethod;

                AnchorsSettingsPanel anchorSP = new AnchorsSettingsPanel(anchorAlignmentMethod.GetAnchors);

                TabPageAdv anchorTabPage = new TabPageAdv(alignmentMethod.MethodName);
                anchorTabPage.Controls.Add(anchorSP);
                anchorSP.Dock            = DockStyle.Fill;
                anchorTabPage.AutoScroll = true;

                result = anchorTabPage;
                break;

            case Template.AlignmentMethodType.Registration:
                Template.RegistrationAlignmentMethod registrationAlignmentMethod = (Template.RegistrationAlignmentMethod)alignmentMethod;

                switch (registrationAlignmentMethod.GetRegistrationMethod.GetRegistrationMethodType)
                {
                case Template.RegistrationAlignmentMethod.RegistrationMethodType.KAZE:
                    Template.RegistrationAlignmentMethod.KazeRegistrationMethod kazeRegistrationMethod = (Template.RegistrationAlignmentMethod.KazeRegistrationMethod)registrationAlignmentMethod.GetRegistrationMethod;

                    KazeSettingsControl kazeSettingsControl = new KazeSettingsControl(kazeRegistrationMethod.GetKazeData, registrationAlignmentMethod.GetUseStoredModelFeatures, registrationAlignmentMethod.PipelineIndex);
                    kazeSettingsControl.OnSetDataEvent += (Template.RegistrationAlignmentMethod.KazeRegistrationMethod.KazeData kazeData, bool useStoredModelFeatures, int pipelineIndex) =>
                    {
                        Template.RegistrationAlignmentMethod _registrationAlignmentMethod = (Template.RegistrationAlignmentMethod)mainAlignmentPipeline[pipelineIndex];
                        string      methodName  = registrationAlignmentMethod.MethodName;
                        IInputArray inputImage  = registrationAlignmentMethod.GetSourceImage;
                        Size        outputWidth = registrationAlignmentMethod.GetOutputWidth;

                        Template.RegistrationAlignmentMethod kazeAlignmentMethod = new Template.RegistrationAlignmentMethod(pipelineIndex, methodName, new Template.RegistrationAlignmentMethod.KazeRegistrationMethod(kazeData), inputImage, outputWidth);
                        testAlignmentPipeline[pipelineIndex] = kazeAlignmentMethod;
                    };
                    kazeSettingsControl.OnResetDataEvent += (object sender, int pipelineIndex) =>
                    {
                        Template.RegistrationAlignmentMethod _registrationAlignmentMethod = (Template.RegistrationAlignmentMethod)mainAlignmentPipeline[pipelineIndex];
                        Template.RegistrationAlignmentMethod.KazeRegistrationMethod _kazeRegistrationMethod = (Template.RegistrationAlignmentMethod.KazeRegistrationMethod)_registrationAlignmentMethod.GetRegistrationMethod;

                        var kSC = (KazeSettingsControl)sender;
                        kSC.InitializeKazePanel(_kazeRegistrationMethod.GetKazeData, _registrationAlignmentMethod.GetUseStoredModelFeatures);

                        testAlignmentPipeline[pipelineIndex] = mainAlignmentPipeline[pipelineIndex];
                    };

                    TabPageAdv kazeTabPage = new TabPageAdv(alignmentMethod.MethodName);
                    kazeTabPage.Controls.Add(kazeSettingsControl);
                    kazeSettingsControl.Dock = DockStyle.Top;
                    kazeTabPage.AutoScroll   = true;

                    result = kazeTabPage;
                    break;

                case Template.RegistrationAlignmentMethod.RegistrationMethodType.AKAZE:
                    Template.RegistrationAlignmentMethod.AKazeRegistrationMethod akazeRegistrationMethod = (Template.RegistrationAlignmentMethod.AKazeRegistrationMethod)registrationAlignmentMethod.GetRegistrationMethod;

                    AKazeSettingsControl aKazeSettingsControl = new AKazeSettingsControl(akazeRegistrationMethod.GetAKazeData, registrationAlignmentMethod.GetUseStoredModelFeatures, registrationAlignmentMethod.PipelineIndex);
                    aKazeSettingsControl.OnSetDataEvent += (Template.RegistrationAlignmentMethod.AKazeRegistrationMethod.AKazeData akazeData, bool useStoredModelFeatures, int pipelineIndex) =>
                    {
                        Template.RegistrationAlignmentMethod _registrationAlignmentMethod = (Template.RegistrationAlignmentMethod)mainAlignmentPipeline[pipelineIndex];
                        string      methodName  = registrationAlignmentMethod.MethodName;
                        IInputArray inputImage  = registrationAlignmentMethod.GetSourceImage;
                        Size        outputWidth = registrationAlignmentMethod.GetOutputWidth;

                        Template.RegistrationAlignmentMethod akazeAlignmentMethod = new Template.RegistrationAlignmentMethod(pipelineIndex, methodName, new Template.RegistrationAlignmentMethod.AKazeRegistrationMethod(akazeData), inputImage, outputWidth);
                        testAlignmentPipeline[pipelineIndex] = akazeAlignmentMethod;
                    };
                    aKazeSettingsControl.OnResetDataEvent += (object sender, int pipelineIndex) =>
                    {
                        Template.RegistrationAlignmentMethod _registrationAlignmentMethod = (Template.RegistrationAlignmentMethod)mainAlignmentPipeline[pipelineIndex];
                        Template.RegistrationAlignmentMethod.AKazeRegistrationMethod _akazeRegistrationMethod = (Template.RegistrationAlignmentMethod.AKazeRegistrationMethod)_registrationAlignmentMethod.GetRegistrationMethod;

                        var akSC = (AKazeSettingsControl)sender;
                        akSC.InitializeAKazePanel(_akazeRegistrationMethod.GetAKazeData, _registrationAlignmentMethod.GetUseStoredModelFeatures);

                        testAlignmentPipeline[pipelineIndex] = mainAlignmentPipeline[pipelineIndex];
                    };

                    TabPageAdv akazeTabPage = new TabPageAdv(alignmentMethod.MethodName);
                    akazeTabPage.Controls.Add(aKazeSettingsControl);
                    aKazeSettingsControl.Dock = DockStyle.Top;
                    akazeTabPage.AutoScroll   = true;

                    result = akazeTabPage;
                    break;
                }
                break;
            }

            return(result);
        }
Пример #5
0
 private void Initialize(Template.AnchorAlignmentMethod anchorAlignmentMethod, Bitmap templateImage)
 {
     SetupForConfigured(anchorAlignmentMethod, templateImage);
 }