public Point3[] FindTempleteModel(int caneraId, int modelId) { CameraMgr.Inst[caneraId].CameraSoft(); if (CameraMgr.Inst[caneraId].WaiteGetImage(1000) == false) { Tool.Shapes[caneraId].OutputResult.Count = 0; return(new Point3[0]); } lock (locker) { HImage image = CameraMgr.Inst[caneraId].GetCurrentImage(); List <Point3> list = new List <Point3>(); try { if (Tool.Shapes[modelId].InputImg != null) { Tool.Shapes[modelId].InputImg.Dispose(); } Tool.Shapes[modelId].InputImg = image; Tool.Shapes[modelId].FindModel(); ShapeMatchResult match = Tool.Shapes[modelId].OutputResult; if (mainCamera[modelId] != null) { mainCamera[modelId].ReDraw(); } if (match.Count > 0) { float row = CameraMgr.Inst[modelId].ImageSize.Height / 2f; float col = CameraMgr.Inst[modelId].ImageSize.Width / 2f; for (int i = 0; i < match.Count; i++) { CalibPointToPoint calib = Tool.Calibs[caneraId]; PointF pf; calib.PixelPointToWorldPoint(new PointF(match.Col[i].F, match.Row[i].F), out pf, new PointF(col, row), new PointF()); Point3 point = new Point3() { X = pf.X, Y = pf.Y, R = match.Angle.TupleDeg()[i].F }; list.Add(point); } } } finally { } return(list.ToArray()); } }
public PointF GetShapeDeviation(CalibPointToPoint calib) { PointF imageCenter = new PointF(); if (Shape.ModelImg != null && Shape.ModelImg.IsInitialized()) { int width, height; Shape.ModelImg.GetImageSize(out width, out height); imageCenter.X = width / 2.0f; imageCenter.Y = height / 2.0f; } else { return(new PointF()); } PointF point = new PointF(); PointF pixel = new PointF(); pixel.X = Shape.ModelImgCol; pixel.Y = Shape.ModelImgRow; calib.PixelPointToWorldPoint(pixel, out point, imageCenter, new PointF()); return(point); }