Пример #1
0
        public void GetCornerResults(ref ezPoint corner)
        {
            try
            {
                float result_CenterX_1 = 0;
                float result_CenterY_1 = 0;
                float result_Angle_1   = 0;

                float result_CenterX_2 = 0;
                float result_CenterY_2 = 0;
                float result_Angle_2   = 0;
                FindCorner[CornerLine.Line_1].FindLine(ref result_CenterX_1, ref result_CenterY_1, ref result_Angle_1);
                FindCorner[CornerLine.Line_2].FindLine(ref result_CenterX_2, ref result_CenterY_2, ref result_Angle_2);

                EPoint localSensor_1 = eFixture.GetPoint(new EPoint(result_CenterX_1, result_CenterY_1), CoordinateHook.NotHook);
                EPoint localSensor_2 = eFixture.GetPoint(new EPoint(result_CenterX_2, result_CenterY_2), CoordinateHook.NotHook);

                ezLine line_1 = new ezLine(localSensor_1.X, localSensor_1.Y, result_Angle_1 + eFixture.Angle);
                ezLine line_2 = new ezLine(localSensor_2.X, localSensor_2.Y, result_Angle_2 + eFixture.Angle);

                line[CornerLine.Line_1] = line_1;
                line[CornerLine.Line_2] = line_2;
                corner = new ezPoint(line_1, line_2);
            }
            catch (EException exc)
            {
                StackFrame[] stackFrames = new StackTrace(true).GetFrames();
                clsLogFile.LogTryCatch(stackFrames, exc.Message, true, true);
            }
            catch (Exception ex)
            {
                StackFrame[] stackFrames = new StackTrace(true).GetFrames();
                clsLogFile.LogTryCatch(stackFrames, ex.Message, true, true);
            }
        }
Пример #2
0
        public void GetLineWordResults(CornerLine cornerLine, ref ezLine line)
        {
            try
            {
                float result_CenterX = 0;
                float result_CenterY = 0;
                float result_Angle   = 0;
                FindCorner[cornerLine].FindLine(ref result_CenterX, ref result_CenterY, ref result_Angle);

                EPoint localSensor = eFixture.GetPoint(new EPoint(result_CenterX, result_CenterY), CoordinateHook.NotHook);
                EPoint world       = eCalibration.Fixture.GetPoint(new EPoint(localSensor.X, localSensor.Y), CoordinateHook.Hook);

                line = new ezLine(world.X, world.Y, result_Angle + eFixture.Angle);
            }
            catch (EException exc)
            {
                StackFrame[] stackFrames = new StackTrace(true).GetFrames();
                clsLogFile.LogTryCatch(stackFrames, exc.Message, true, true);
            }
            catch (Exception ex)
            {
                StackFrame[] stackFrames = new StackTrace(true).GetFrames();
                clsLogFile.LogTryCatch(stackFrames, ex.Message, true, true);
            }
        }
Пример #3
0
        public frmEVision()
        {
            InitializeComponent();
            cboCalibrFindMode.DataSource        = Enum.GetValues(typeof(EFindContrastMode));
            cboFindMode.DataSource              = Enum.GetValues(typeof(EFindContrastMode));
            cboLine_1_TransitionType.DataSource = Enum.GetValues(typeof(ETransitionType));
            cboLine_2_TransitionType.DataSource = Enum.GetValues(typeof(ETransitionType));

            Directory.CreateDirectory(visionPath + "\\" + visionFile);
            openFileDialog = new OpenFileDialog();
            saveFileDialog = new SaveFileDialog();

            eCalibration       = new clsEasyCalibration(picDisplay);
            eCalibrFindPattern = new clsEasyFindPattern(picDisplay);
            calibrPoint        = new List <CalibrationPoint>();
            eFindPattern       = new clsEasyFindPattern(picDisplay);

            eFindLine_1 = new clsEasyFindLine(picDisplay);
            eFindLine_2 = new clsEasyFindLine(picDisplay);

            eFixture = new clsEasyFixture(picDisplay);
            eFindLine_1.Base.Attach(eFixture.Base);
            eFindLine_2.Base.Attach(eFixture.Base);

            line_1 = new ezLine(0, 0, 0);
            line_2 = new ezLine(0, 0, 0);

            dgvCalibrPointTable.DataSource   = eCalibration.CalibrTable;
            dgvCalibrPatternTable.DataSource = eCalibrFindPattern.PatternTable;
            dgvPatternTable.DataSource       = eFindPattern.PatternTable;
            dgvLine_1_SampleTable.DataSource = eFindLine_1.SampleTable;
            dgvLine_2_SampleTable.DataSource = eFindLine_2.SampleTable;
        }
Пример #4
0
        public ezPoint(ezLine line_1, ezLine line_2)
        {
            //解聯立方程式
            double a       = line_1.a - line_2.a;
            double c       = line_1.c - line_2.c;
            double cornerX = -c / a;
            double cornerY = (line_1.a * cornerX) + line_1.c;

            this.x = cornerX;
            this.y = cornerY;
        }
Пример #5
0
        public ezAngle(ezLine line_1, ezLine line_2)
        {
            double sqra1 = Math.Pow(line_1.a, 2);
            double sqrb1 = Math.Pow(line_1.b, 2);
            double sqra2 = Math.Pow(line_2.a, 2);
            double sqrb2 = Math.Pow(line_2.b, 2);

            angle = Math.Acos(
                (line_1.a * line_2.a + line_1.b * line_2.b) /
                (Math.Sqrt(sqra1 + sqrb1) *
                 Math.Sqrt(sqra2 + sqrb2))) * 180 / Math.PI;
        }
Пример #6
0
        private void btnLine_2_GetSample_Click(object sender, EventArgs e)
        {
            eFindLine_2.SetROIEnd();

            float result_CenterX = 0;
            float result_CenterY = 0;
            float result_Angle   = 0;

            eFindLine_2.FindLine(ref result_CenterX, ref result_CenterY, ref result_Angle);

            EPoint localSensor = eFixture.GetPoint(new EPoint(result_CenterX, result_CenterY), CoordinateHook.NotHook);
            EPoint world       = eCalibration.Fixture.GetPoint(new EPoint(localSensor.X, localSensor.Y), CoordinateHook.Hook);

            txtLine_2_Results_Center.Text = "X:" + world.X.ToString("0.000") + " " + "Y:" + world.Y.ToString("0.000");
            txtLine_2_Results_Angle.Text  = result_Angle.ToString("0.000");
            eFindLine_2.GetSample();
            eFindLine_2.ShowResult();

            line_2 = new ezLine(world.X, world.Y, result_Angle);
        }