Exemplo n.º 1
0
        public void Jesus()
        {
            workspace = control.Workspaces.Add("workspace");

            stream = workspace.Streams.Add("default");

            blue  = stream.Tools.Add("localize", ToolType.Blue) as IBlueTool;
            red   = stream.Tools.Add("analyze", ToolType.Red) as IRedTool;
            green = stream.Tools.Add("classify", ToolType.Green) as IGreenTool;
        }
Exemplo n.º 2
0
        private void MakeConfusionMatrix()
        {
            int totalGrid = classList.Count + 1; // Class Label도 있기 때문에 1개 추가

            double[,] tempConfusionMatrix = new double[classList.Count, classList.Count];

            Grid thisGrid;

            switch (tabNumber)
            {
            case 0:
                thisGrid = Test_Grid;
                break;

            case 1:
                thisGrid = Train_Grid;
                break;

            case 2:
                thisGrid = All_Grid;
                break;

            default:
                return;
            }

            thisGrid.Children.Clear();
            thisGrid.RowDefinitions.Clear();
            thisGrid.ColumnDefinitions.Clear();


            for (int gridNum = 0; gridNum < totalGrid; gridNum++)
            {
                ColumnDefinition tempCol = new ColumnDefinition();
                thisGrid.ColumnDefinitions.Add(tempCol);
                tempCol.Width = gridNum == 0 ? new GridLength(40) : new GridLength(1, GridUnitType.Star);

                RowDefinition tempRow = new RowDefinition();
                thisGrid.RowDefinitions.Add(tempRow);
                tempRow.Height = gridNum == 0 ? new GridLength(40) : new GridLength(1, GridUnitType.Star);
            }


            for (int col = 0; col < totalGrid; col++)
            {
                for (int row = 0; row < totalGrid; row++)
                {
                    if (row == 0 && col == 0)
                    {
                        continue;
                    }

                    if (row == 0 || col == 0)
                    {
                        TextBlock tempTextBlock = new TextBlock();
                        Grid.SetColumn(tempTextBlock, col);
                        Grid.SetRow(tempTextBlock, row);
                        tempTextBlock.Text                = col == 0 ? classList[row - 1] : classList[col - 1];
                        tempTextBlock.FontWeight          = FontWeights.Bold;
                        tempTextBlock.VerticalAlignment   = VerticalAlignment.Center;
                        tempTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
                        thisGrid.Children.Add(tempTextBlock);
                    }
                    else
                    {
                        string filter = MakeResultFilter(col, row);

                        IGreenTool tool      = context.MainWindow.ToolChainViewModel.Tool as IGreenTool;
                        var        database  = tool.Database;
                        var        tempList  = database.List(filter);
                        int        countView = tempList.Count;

                        tempConfusionMatrix[col - 1, row - 1] = countView;

                        Button tempButton = new Button();
                        tempButton.Content    = countView;
                        tempButton.FontWeight = row == col ? FontWeights.Bold : FontWeights.Normal;
                        tempButton.Foreground = row > col ? Brushes.Blue : Brushes.Red;
                        if (row == col || countView == 0)
                        {
                            tempButton.Foreground = Brushes.Black;
                        }
                        tempButton.Tag             = filter;
                        tempButton.Click          += new RoutedEventHandler(ConfusionMatrixValue_Btn_Click);
                        tempButton.Background      = Brushes.White;
                        tempButton.BorderThickness = new Thickness(0);
                        Grid.SetColumn(tempButton, col);
                        Grid.SetRow(tempButton, row);
                        thisGrid.Children.Add(tempButton);
                    }
                }
            }

            confusionMatrix = tempConfusionMatrix;
        }
Exemplo n.º 3
0
        void Run()
        {
            try {
                ITool currentTool = context.MainWindow.ToolChain.Tool;
                if (currentTool.Type == ViDi2.ToolType.Blue && ((IBlueTool)currentTool).Models.Count() > 0)
                {
                    IBlueTool             blueTool  = (IBlueTool)currentTool;
                    IGreenTool            greenTool = (IGreenTool)currentTool.Children.Add("Green", ViDi2.ToolType.Green);
                    IBlueRegionOfInterest blueROI   = (IBlueRegionOfInterest)greenTool.RegionOfInterest;
                    blueROI.Model = ((IBlueTool)currentTool).Models.First();
                    double fsize = currentTool.Parameters.FeatureSize * 2;
                    blueROI.Size = new System.Windows.Size(fsize, fsize);

                    greenTool.Database.Process("", false);

                    var greenViews = greenTool.Database.List("");
                    var blueViews  = blueTool.Database.List("");

                    string previousFilename = "";

                    using (greenTool.Database.DeferChangedSignal())
                    {
                        foreach (var blueKeyPair in blueViews)
                        {
                            if (blueKeyPair.Key.Filename != previousFilename)
                            {
                                previousFilename = blueKeyPair.Key.Filename;

                                var blueMarking  = blueTool.Database.GetMarking(blueKeyPair.Key.Filename);
                                var greenMarking = greenTool.Database.GetMarking(blueKeyPair.Key.Filename);

                                int matchNumber = 0;

                                foreach (var blueView in blueMarking.Views)
                                {
                                    if (blueView is ViDi2.IBlueLabeledView)
                                    {
                                        var labeledBlueView = (ViDi2.IBlueLabeledView)blueView;

                                        foreach (var match in labeledBlueView.Matches)
                                        {
                                            char   closestFeatureId = '0';
                                            double closestDistance  = Double.MaxValue;

                                            foreach (var labeledMatch in labeledBlueView.LabeledMatches)
                                            {
                                                double length = (match.Position - labeledMatch.Position).Length;
                                                if (length < closestDistance)
                                                {
                                                    closestFeatureId = labeledMatch.Features.First().Id;
                                                    closestDistance  = length;
                                                }
                                            }

                                            var key = new ViewKey(blueKeyPair.Key.Filename, matchNumber);

                                            if (closestDistance < fsize / 4)
                                            {
                                                greenTool.Database.Tag(key.ToFilterString(), "" + closestFeatureId);
                                            }
                                            else
                                            {
                                                greenTool.Database.Tag(key.ToFilterString(), "False positive");
                                            }

                                            ++matchNumber;
                                        }
                                    }
                                    else
                                    {
                                        matchNumber += blueView.Matches.Count;
                                    }
                                }
                            }
                        }
                    }
                    System.Windows.MessageBox.Show("Done!");
                }
                else
                {
                    System.Windows.MessageBox.Show("The current tool is not a blue tool having at least one model.");
                }
            }
            catch (Exception e)
            {
                System.Windows.MessageBox.Show(e.Message);
            }
        }