代码:
Mat mat = new Mat(600, 800, MatType.CV_8UC3);
Point p1 = new Point(100, 100);
Point p2 = new Point(400, 400);
//画点
Cv2.Circle(mat, p1, 3, Scalar.Red, -1);
Cv2.Circle(mat, p2, 3, Scalar.Red, -1);
mat.PutText("p1", p1- new Point(50,0), HersheyFonts.HersheyDuplex, 1d, Scalar.Lime);
mat.PutText("p2", p2 + new Point(20, 0), HersheyFonts.HersheyDuplex, 1d, Scalar.Lime);
//在两点间画线
Cv2.Line(mat, p1, p2, Scalar.Red);
//求中点
var p3 = p1+p2;
Point p0 = new Point(p3.X / 2, p3.Y / 2);
//计算两点距离
var d = p1.DistanceTo(p2);
mat.PutText(d.ToString("F2"), p0, HersheyFonts.HersheyDuplex, 1d, Scalar.Lime);
结果: