private void btn_Test_Click(object sender, RoutedEventArgs e)
{
CogFitCircle cogFitCircle = new CogFitCircle();
cogFitCircle.AddPoint(0, 10);
cogFitCircle.AddPoint(10, 0);
cogFitCircle.AddPoint(0, -10);
cogFitCircle.AddPoint(-10, 0);
CogFitCircleResult res = cogFitCircle.Execute("@");
CogCircle cogCircle = res.GetCircle();
MessageBox.Show($"cx = {cogCircle.CenterX:F3} cy = {cogCircle.CenterY:F3} r = {cogCircle.Radius}");
CogNPointToNPoint cogNP = new CogNPointToNPoint();
cogNP.AddPointPair(100, 100, 10, 10);
cogNP.AddPointPair(150, 100, 15, 10);
cogNP.AddPointPair(200, 100, 20, 10);
cogNP.AddPointPair(200, 150, 20, 15);
cogNP.AddPointPair(150, 150, 15, 15);
cogNP.AddPointPair(100, 150, 10, 15);
cogNP.AddPointPair(100, 200, 10, 20);
cogNP.AddPointPair(150, 200, 15, 20);
cogNP.AddPointPair(200, 200, 20, 20);
ICogTransform2D trans = cogNP.ComputeGroupAFromGroupBTransform(out double rmsError);
cogNP.ComputationMode = CogCalibFixComputationModeConstants.Linear;
double or_x = 13, or_y = 14;
trans.MapPoint(or_x, or_y, out double x, out double y);
CogTransform2DLinear linear = trans as CogTransform2DLinear;
double r = linear.MapAngle(Math.PI);
MessageBox.Show($"or_x = {x:F3} or_y = {y:F3} r = {r:F3} RMSERROR = {rmsError}");
}
输出:
标签:10,200,20,AddPointPair,cogNP,150,CogFitCircle,CogNPointToNPoint,Cognex From: https://www.cnblogs.com/huvjie/p/17956395