using Rs.Framework; using Rs.MotionPlat.Flow; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Rs.MotionPlat.SysConfig { public partial class UpCameraCalibration : BaseForm { public UpCameraCalibration() { InitializeComponent(); cameraTemplate1.ItemName = "上相机标定"; } private void UpCameraCalibration_FormClosing(object sender, FormClosingEventArgs e) { cameraTemplate1.RemoveGrabEvent(); } private void btnMove_Click(object sender, EventArgs e) { AxisControl.LoadY.MoveOffset(double.Parse(txtMoveOffset.Text), 10); } private void btnCalcPix_Click(object sender, EventArgs e) { int count = dgvPixCalib.Rows.Count; if (count < 2) { Msg.ShowError("移动次数少于一次"); return; } double columnValY1 = double.Parse(dgvPixCalib.Rows[0].Cells[0].Value.ToString()); double columnValY2 = double.Parse(dgvPixCalib.Rows[1].Cells[0].Value.ToString()); double mmPerPix = (double.Parse(txtMoveOffset.Text) / (columnValY2 - columnValY1)); txtMmPerPixX.Text = mmPerPix.ToString("0.0000"); txtMmPerPixY.Text = mmPerPix.ToString("0.0000"); } private void btnGetMatchResult_Click(object sender, EventArgs e) { cameraTemplate1.GetMatchResult(out double row, out double column, out double angle, out double score); int rowIndex = dgvPixCalib.Rows.Add(); dgvPixCalib.Rows[rowIndex].Cells[0].Value = row.ToString("0.000"); dgvPixCalib.Rows[rowIndex].Cells[1].Value = column.ToString("0.000"); dgvPixCalib.Rows[rowIndex].Cells[2].Value = angle.ToString("0.000"); dgvPixCalib.Rows[rowIndex].Cells[3].Value = score.ToString("0.000"); Msg.ShowInfo($"{row},{column},{angle},{score}"); } private void UpCameraCalibration_Load(object sender, EventArgs e) { dgvPixCalib.AutoGenerateColumns = false; } protected override void OnClosed(EventArgs e) { cameraTemplate1.StopGrab(); base.OnClosed(e); } } }