Exemplo n.º 1
0
        public void FindModel(string fileName, out HTuple row, out HTuple col, out HTuple angle, out HTuple score)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            HGraphics.display();
            HOperatorSet.SetColor(hWindowControl.HalconWindow, "green");

            MatchingModelParam modelParam = MatchingParameters.deserialize(fileName);

            modelParam.findModel(HGraphics.allObj["pic"], out row, out col, out angle, out score);

            HOperatorSet.DispCross(hWindowControl.HalconWindow, row, col, 100, 0);
            stopwatch.Stop();
            string s = string.Format("\n{0,15} {1,15} {2,15} {3,15}\n", "Row", "Col", "Phi", "Score");

            for (int i = 0; i < score.Length; i++)
            {
                s += string.Format("{0,15} {1,15} {2,15} {3,15}\n", Math.Round(row[i].D, 2).ToString(), Math.Round(col[i].D, 2).ToString(),
                                   Math.Round(angle[i].D, 2).ToString(), Math.Round(score[i].D, 2).ToString());
            }
            Log(s);
            Log("Instance found: " + score.Length.ToString());
            Log("Duration: " + stopwatch.Elapsed.TotalSeconds.ToString() + " s");
        }
        public void findModel(HObject Image, out HTuple Row, out HTuple Column, out HTuple Angle, out HTuple Score)
        {
            Row    = new HTuple();
            Column = new HTuple();
            Angle  = new HTuple();
            Score  = new HTuple();

            try
            {
                MatchingModelParam param = new MatchingModelParam(ModelCenterRow, ModelCenterCol, AngleStart, AngleExtent,
                                                                  minScoreScroll.Value / 100.0, OptimizationComboBox.SelectedItem.ToString().Replace(' ', '_'), contrastBar.Value, HGraphics.allObj, NumMatches,
                                                                  OverlapScroll.Value / 100.0, SubPixComboBox.SelectedItem.ToString(), GreedinessScroll.Value / 100.0, NumLevels);
                param.findModel(Image, out Row, out Column, out Angle, out Score);
            }
            catch (Exception ex)
            {
                this.ErrorMessage.Text = ex.Message;
            }
        }