public static PointF[] FindChessboardCorners(
Image<Gray, Byte> image,
Size patternSize,
CvEnum.CALIB_CB_TYPE flags)
{
int cornerCount = 0;
PointF[] corners = new PointF[patternSize.Width * patternSize.Height];
GCHandle handle = GCHandle.Alloc(corners, GCHandleType.Pinned);
bool patternFound =
CvInvoke.cvFindChessboardCorners(
image.Ptr,
patternSize,
handle.AddrOfPinnedObject(),
ref cornerCount,
flags) != 0;
handle.Free();
if (cornerCount != corners.Length)
Array.Resize(ref corners, cornerCount);
return patternFound ? corners : null;
}