/// <summary> /// Rotate the single channel Nx2 matrix where N is the number of 2D points. The value of the matrix is changed after rotation. /// </summary> /// <typeparam name="TDepth">The depth of the points, must be double or float</typeparam> /// <param name="points">The N 2D-points to be rotated</param> public void RotatePoints <TDepth>(Matrix <TDepth> points) where TDepth : new() { Debug.Assert(typeof(TDepth) == typeof(float) || typeof(TDepth) == typeof(Double), "Only type of double or float is supported"); Debug.Assert(points.NumberOfChannels == 1 && points.Cols == 2, "The matrix must be a single channel Nx2 matrix where N is the number of points"); CvEnum.DepthType dt = CvInvoke.GetDepthType(typeof(TDepth)); using (Mat tmp = new Mat(points.Rows, 3, CvInvoke.GetDepthType(typeof(TDepth)), 1)) using (Mat rotationMatrix = new Mat(Rows, Cols, CvInvoke.GetDepthType(typeof(TDepth)), 1)) { CvInvoke.CopyMakeBorder(points, tmp, 0, 0, 0, 1, Emgu.CV.CvEnum.BorderType.Constant, new MCvScalar(1.0)); if (typeof(double).Equals(typeof(TDepth))) { CopyTo(rotationMatrix); } else { ConvertTo(rotationMatrix, CvInvoke.GetDepthType(typeof(TDepth))); } CvInvoke.Gemm( tmp, rotationMatrix, 1.0, null, 0.0, points, Emgu.CV.CvEnum.GemmType.Src2Transpose); } }