public static FaceLib GetInstance()
 {
     if (instance == null)
     {
         lock (Lock)
         {
             if (instance == null)
             {
                 instance = new FaceLib();
             }
         }
     }
     return(instance);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 4
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     FaceLib.GetInstance().Uninit();
 }