Example #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");
        }
Example #2
0
 //viewModel_Click calls up open file dialog(.mod) and deserialize the file to MatchingModelParam, which contains graphics of
 //the matching model. Graphics are copied to HGraphics and displayed
 private void viewModel_Click(object sender, EventArgs e)
 {
     try
     {
         if (openShapeModel.ShowDialog() == DialogResult.OK)
         {
             MatchingModelParam param = MatchingParameters.deserialize(openShapeModel.FileName);
             HGraphics.allObj = param.allObj;
             hWindowControl.SetFullImagePart(new HImage(HGraphics.allObj["pic"]));
             HGraphics.display();
             Log("Open model " + Path.GetFileName(openShapeModel.FileName));
         }
     }
     catch (Exception ex)
     {
         Log(ex.ToString() + "\n");
     }
 }
Example #3
0
 /*findModelToolStripMenuItem_Click creates a MatchingParameters form and let user change matching parameters and
  * find model*/
 private void findModelToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (openShapeModel.ShowDialog() == DialogResult.OK)
         {
             HGraphics.keepOnly(new string[] { "pic" });
             HGraphics.display();
             if (Form2 != null)
             {
                 DisposeMatchingForm();
             }
             Form2 = new MatchingParameters(MatchingParameters.deserialize(openShapeModel.FileName));
             Form2.Show();
             Form2.FindButton.Click += findModelClick;
         }
     }
     catch (Exception ex)
     {
         Log(ex.ToString() + "\n");
     }
 }