/// <summary>
        /// تمرین تشخیص چهره
        /// </summary>
        private void trainFaceRecognizer()
        {
            ///[Traitning Face Recognizer]
            List <Image <Gray, byte> > images = new List <Image <Gray, byte> >();
            List <int> labels = new List <int>();

            FaceRepository.OpenFacesDatabase(ref images, ref labels);

            if (images.Count > 0 && labels.Count > 0)
            {
                m_faceRecognizer.Train(images.ToArray(), labels.ToArray());
            }
            ///[Traitning Face Recognizer]
        }
        /// <summary>
        /// شناسایی چهره
        /// </summary>
        /// <param name="bitmap">تصویر حاوی صورت</param>
        /// <returns>شناسه</returns>
        public string RecognizeFace(Bitmap bitmap)
        {
            Console.WriteLine("[{0}] Recognizing face...", DateTime.Now.ToString("HH:mm:ss"));
            ///[Recognizing face]
            FaceRecognizer.PredictionResult predicitonResult = m_faceRecognizer.Predict(new Image <Gray, byte>(bitmap));
            if (predicitonResult.Label == -1)
            {
                return(string.Empty);
            }

            string id = FaceRepository.GetId(predicitonResult.Label);

            ///[Recognizing face]
            if (!string.IsNullOrEmpty(id))
            {
                Console.WriteLine("[{0}] face id {1} was recognized...", DateTime.Now.ToString("HH:mm:ss"), id);
            }
            return(id);
        }
        /// <summary>
        /// دخیره سازی تصویر صورت
        /// </summary>
        /// <param name="bitmap">تصویر</param>
        /// <param name="id">شناسه خارجی</param>
        public static void SaveFaceBitmap(Bitmap bitmap, string id)
        {
            ///[Saving face bitmap]
            int key = FaceRepository.getKey(id);

            if (m_storageMethod == StorageMethod.ZipArchive)
            {
                m_facePictureRepository.Save(string.Format(@"{0}\{1}.jpg", key, Guid.NewGuid()), bitmap);
            }

            ///[Saving face bitmap]
            else if (m_storageMethod == StorageMethod.Directory)
            {
                if (!Directory.Exists(string.Format(@"faces\{0}", key)))
                {
                    Directory.CreateDirectory(string.Format(@"faces\{0}", key));
                }

                bitmap.Save(string.Format(@"faces\{0}\{1}.jpg", key, Guid.NewGuid()), ImageFormat.Jpeg);
            }

            m_xmlKeyValueDatabase[Convert.ToString(key)] = id;
        }
 /// <summary>
 /// حذف چهره
 /// </summary>
 /// <param name="id">شناسه خارجی</param>
 public void DeleteFace(string id)
 {
     FaceRepository.DeleteFace(id);
 }
 /// <summary>
 /// ذخیره چهره
 /// </summary>
 /// <param name="bitmap">تصویر چهره</param>
 /// <param name="id">شناسه خارجی</param>
 public void SaveFace(Bitmap bitmap, string id)
 {
     FaceRepository.SaveFaceBitmap(bitmap, id);
 }