Emgu.CV.CvInvoke.CvFaceRecognizerTrain C# (CSharp) Метод

CvFaceRecognizerTrain() приватный Метод

private CvFaceRecognizerTrain ( IntPtr recognizer, IntPtr images, IntPtr labels, int count ) : void
recognizer IntPtr
images IntPtr
labels IntPtr
count int
Результат void
        internal static extern void CvFaceRecognizerTrain(IntPtr recognizer, IntPtr images, IntPtr labels, int count);

Usage Example

Пример #1
0
        /// <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();
            }
        }
CvInvoke