public static Point GetCenter(MatOfPoint matOfPoint) { var points = matOfPoint.toArray(); var minX = points.OrderBy(e => e.x).First().x; var minY = points.OrderBy(e => e.y).First().y; return(new Point(minX + ((double)matOfPoint.width()) / 2.0, ((double)matOfPoint.height()) / 2.0)); }