Exemple #1
0
 private void ToolStripMenuItemSetCalibration_Click(object sender, EventArgs e)
 {
     if (m_calibrateShow == null || m_calibrateShow.IsDisposed)
     {
         m_calibrateShow = new CalibrationSetForm();
     }
     m_calibrateShow.Show();
     m_calibrateShow.Focus();
 }
Exemple #2
0
        private int TriggerCamera(double robotX, double robotY, double robotRz)
        {
            Tool.DebugInfo.OutputProcessMessage("Integraton TriggerCamera beg< ");
            int locationResult = -1;

            try
            {
                if (m_templateSet.IsDisposed || m_templateSet == null)
                {
                    m_templateSet = new TemplateSetForm();
                }
                if (m_calibrateShow.IsDisposed || m_calibrateShow == null)
                {
                    m_calibrateShow = new CalibrationSetForm();
                }
                checkBoxCameraAcquisition.Invoke(new MethodInvoker(delegate
                {
                    aqDisplayLocation.InteractiveGraphics.Clear();
                    aqDisplayLocation.Update();
                    if (checkBoxCameraAcquisition.Checked)
                    {
                        checkBoxCameraAcquisition.Checked = false;
                        checkBoxCameraAcquisition_CheckedChanged(null, null);
                        m_templateSet.ImageInput = aqDisplayLocation.Image.Clone() as Bitmap;
                    }
                    else
                    {
                        Tool.DebugInfo.OutputProcessMessage("Integraton Integraton TriggerCamera acquisition beg< ");
                        Bitmap location  = null;
                        Bitmap detection = null;
                        m_Acquisition.Acquisition(ref location, ref detection); //853
                        aqDisplayLocation.Invoke(new MethodInvoker(delegate
                        {
                            aqDisplayLocation.Image = location;
                            aqDisplayLocation.FitToScreen();
                            aqDisplayLocation.Update();
                        }));
                        if (m_templateSet.ImageInput != null)//936.9
                        {
                            m_templateSet.ImageInput.Dispose();
                        }
                        m_templateSet.ImageInput = location.Clone() as Bitmap;
                        Tool.DebugInfo.OutputProcessMessage("Integraton TriggerCamera acquisition end> ");
                    }


                    triggerLocationResult.Clear();
                    locationResult = m_templateSet.RunMatcher(Application.StartupPath + @"\location\ModelNormal.shm");

                    if (locationResult == 0)
                    {
                        for (int i = 0; i < m_templateSet.LocationResultPosTheta.Length; i++)
                        {
                            LocationResultSet result = new LocationResultSet();
                            result.CenterX           = m_templateSet.LocationResultPosX[i];
                            result.CenterY           = m_templateSet.LocationResultPosY[i];
                            result.Posture           = ProductPosture.Normal;
                            result.Angle             = m_templateSet.LocationResultPosTheta[i];
                            result.Transmited        = false;
                            result.Score             = m_templateSet.Score[i];
                            triggerLocationResult.Add(result);
                            m_templateSet.ShowGetResultsData(AqColorConstants.Green, aqDisplayLocation);
                        }
                    }
                    if (triggerLocationResult.Count == 0) //未抓到水平放置,才去抓取竖直放置
                    {
                        locationResult = m_templateSet.RunMatcher(Application.StartupPath + @"\location\ModelVertical.shm");
                        if (locationResult == 0)
                        {
                            for (int i = 0; i < m_templateSet.LocationResultPosTheta.Length; i++)
                            {
                                LocationResultSet result = new LocationResultSet();
                                result.CenterX           = m_templateSet.LocationResultPosX[i];
                                result.CenterY           = m_templateSet.LocationResultPosY[i];
                                result.Posture           = ProductPosture.Vertical;
                                result.Angle             = m_templateSet.LocationResultPosTheta[i];
                                result.Transmited        = false;
                                result.Score             = m_templateSet.Score[i];
                                triggerLocationResult.Add(result);
                                m_templateSet.ShowGetResultsData(AqColorConstants.Green, aqDisplayLocation);
                            }
                        }
                    }

                    Tool.DebugInfo.OutputProcessMessage("Integraton TriggerCamera RunMatcher end> ");
                    m_calibrateShow.SetCurrentRobotPosition(robotX, robotY, robotRz);
                    //AddMessageToListView("Suc");
                    string showScoreAll = null;
                    for (int i = 0; i < triggerLocationResult.Count; i++)
                    {
                        showScoreAll += (triggerLocationResult[i].Score * 100).ToString("f3") + "\n";
                    }
                    labelLocationScore.Text      = showScoreAll;
                    labelLocationScore.ForeColor = Color.Lime;

                    if (triggerLocationResult.Count == 1)
                    {
                        locationResult = 1; //定位到1个产品
                    }
                    else if (triggerLocationResult.Count == 2)
                    {
                        locationResult = 2; //定位到1个产品
                    }
                    else if (triggerLocationResult.Count > 2)
                    {
                        locationResult = triggerLocationResult.Count;
                    }
                }));
                //SaveImageToFile(aqDisplayLocation, m_templateSet.ImageInput, @"D:\Location\");//1146.88
                //AddMessageToListView("TriggerCameraDone");

                GC.Collect();
                Tool.DebugInfo.OutputProcessMessage("Integraton TriggerCamera collect ------------------");
            }
            catch (Exception ex)
            {
                //MessageBox.Show("TriggerCamera " + ex.Message);
                locationResult = -2;
            }
            m_locationCount++;
            Tool.DebugInfo.OutputProcessMessage(string.Format("Integraton TriggerCamera locationResult = {0}", locationResult));
            return(locationResult);
        }