public static RotationMatrix2D<double> EstimateRigidTransform(PointF[] src, PointF[] dest, bool fullAffine)
{
RotationMatrix2D<double> result = new RotationMatrix2D<double>();
GCHandle handleA = GCHandle.Alloc(src, GCHandleType.Pinned);
GCHandle handleB = GCHandle.Alloc(dest, GCHandleType.Pinned);
bool success;
using (Matrix<float> a = new Matrix<float>(src.Length, 1, 2, handleA.AddrOfPinnedObject(), 2 * sizeof(float)))
using (Matrix<float> b = new Matrix<float>(dest.Length, 1, 2, handleB.AddrOfPinnedObject(), 2 * sizeof(float)))
{
success = CvInvoke.cvEstimateRigidTransform(a, b, result, fullAffine);
}
handleA.Free();
handleB.Free();
if (success)
{
return result;
}
else
{
result.Dispose();
return null;
}
}