/// <summary>
/// Train the face recognizer with the specific images and labels
/// </summary>
/// <param name="images">The images used in the training</param>
/// <param name="labels">The labels of the images</param>
public void Train(IImage[] images, int[] labels)
{
Debug.Assert(images.Length == labels.Length, "The number of labels must equals the number of images");
IntPtr[] ptrs = new IntPtr[images.Length];
for (int i = 0; i < images.Length; i++)
{
ptrs[i] = images[i].Ptr;
}
GCHandle imagesHandle = GCHandle.Alloc(ptrs, GCHandleType.Pinned);
GCHandle labelsHandle = GCHandle.Alloc(labels, GCHandleType.Pinned);
try
{
CvInvoke.CvFaceRecognizerTrain(_ptr, imagesHandle.AddrOfPinnedObject(), labelsHandle.AddrOfPinnedObject(), images.Length);
}
finally
{
imagesHandle.Free();
labelsHandle.Free();
}
}