public static FaceLib GetInstance()
 {
     if (instance == null)
     {
         lock (Lock)
         {
             if (instance == null)
             {
                 instance = new FaceLib();
             }
         }
     }
     return(instance);
 }
Beispiel #2
0
        private Bitmap GetResizeBitmap(Image src)
        {
            Bitmap copy = new Bitmap(src);
            int    mMax = Math.Max(copy.Width, copy.Height);

            try
            {
                if (mMax > 480)
                {
                    float persent = 480.0f / mMax;
                    return(FaceLib.ResizeImage(copy, persent));
                }
            }
            catch (Exception E)
            {
                //
            }

            return(copy);
        }
Beispiel #3
0
        private void DetectPicture(Image imageParam)
        {
            Bitmap bitmap = new Bitmap(imageParam);

            int faceNum = FaceLib.GetInstance().FaceDetect(bitmap, bitmap.Width, bitmap.Height, out List <FaceLibRect> rects);

            if (faceNum > 0)
            {
                Bitmap tmp  = new Bitmap(imageParam);
                string info = $"人脸数目{faceNum}\n";
                int    i    = 0;
                foreach (var rect in rects)
                {
                    DrawRectangleInPicture(tmp, rect.rect, i);
                    info += $"置信度:{rect.confindence}, 角度{rect.angle}, 人脸{i++}\n";
                }

                pictureBox2.Image = tmp;
                label1.Text       = info;
            }
        }
Beispiel #4
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     FaceLib.GetInstance().Uninit();
 }