Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Bitmap        Bitmap = new Bitmap(path);
            var           sid    = SeetaFace.bitmaptoImagedat(Bitmap);
            StringBuilder sb     = new StringBuilder(15000);

            SeetaFace.DetectFace(sid, sb);
            JsonSerializer serializer = new JsonSerializer();
            var            faces      = serializer.Deserialize <SeetaFace.SeetaRect[]>(
                new JsonTextReader(
                    new StringReader(sb.ToString())
                    )
                );
            Graphics g = Graphics.FromImage(Bitmap);
            Pen      p = new Pen(Color.Red);

            for (int i = 0; i < faces.Count(); i++)
            {
                Rectangle rt = new Rectangle()
                {
                    X = faces[i].x, Y = faces[i].y, Width = faces[i].width, Height = faces[i].height
                };
                g.DrawRectangle(p, rt);
                pictureBox2.Image = Bitmap;
            }

            //Rect rect = new Rect(faces[0].x, faces[0].y, faces[0].width, faces[0].height);
            //Bitmap newBitmap = new Bitmap(Bitmap,rect);
            //Cv2.ImShow("111", newBitmap);
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //string path = Application.StartupPath;
            Bitmap Bitmap = new Bitmap(path1);
            var    sid    = SeetaFace.bitmaptoImagedat(Bitmap);
            var    result = SeetaFace.FaceAntiSpoofing(sid, 0);

            switch (result)
            {
            case 0:
                MessageBox.Show("真实人脸");
                break;

            case 1:

                MessageBox.Show("假人脸");
                break;

            case 2:
                MessageBox.Show("无法判断");
                break;

            case 3:
                MessageBox.Show("正在检测");
                break;
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Bitmap        Bitmap1 = new Bitmap(path1);
            StringBuilder sb2     = new StringBuilder(15000);
            var           sid1    = SeetaFace.bitmaptoImagedat(Bitmap1);

            SeetaFace.AgeGender aa = SeetaFace.AgeandGender(sid1);
            string gender          = string.Empty;
            string eye_left        = string.Empty;
            string eye_right       = string.Empty;

            if (aa.gender == 1)
            {
                gender = "女";
            }
            else
            {
                gender = "男";
            }
            if (aa.eye_left == 0)
            {
                eye_left = "闭眼";
            }
            else if (aa.eye_left == 1)
            {
                eye_left = "睁眼";
            }
            else if (aa.eye_left == 2)
            {
                eye_left = "不是眼睛区域";
            }
            else
            {
                eye_left = "未识别";
            }

            if (aa.eye_right == 0)
            {
                eye_right = "闭眼";
            }
            else if (aa.eye_right == 1)
            {
                eye_right = "睁眼";
            }
            else if (aa.eye_right == 2)
            {
                eye_right = "不是眼睛区域";
            }
            else
            {
                eye_right = "未识别";
            }
            MessageBox.Show("年龄:" + aa.age + "性别:" + gender + "左眼" + eye_left + "右眼" + eye_right);
        }
Beispiel #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            Bitmap bit    = new Bitmap(path1);
            var    sid    = SeetaFace.bitmaptoImagedat(bit);
            var    result = SeetaFace.MaskDetect(sid);

            if (result > 0.5)
            {
                MessageBox.Show("佩戴口罩");
            }
            else
            {
                MessageBox.Show("未佩戴口罩");
            }
        }
Beispiel #5
0
        private void button5_Click(object sender, EventArgs e)
        {
            Bitmap        Bitmap1 = new Bitmap(path1);
            Bitmap        Bitmap2 = new Bitmap(path2);
            StringBuilder sb1     = new StringBuilder(15000);
            StringBuilder sb2     = new StringBuilder(15000);
            var           sid1    = SeetaFace.bitmaptoImagedat(Bitmap1);
            var           sid2    = SeetaFace.bitmaptoImagedat(Bitmap2);

            SeetaFace.GetFeature(sid1, sb1);
            SeetaFace.GetFeature(sid2, sb2);
            var score = SeetaFace.CalculateSimilarity(sb1.ToString(), sb2.ToString());

            MessageBox.Show((score * 100).ToString());
        }
Beispiel #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            Bitmap        Bitmap = new Bitmap(path);
            var           sid    = SeetaFace.bitmaptoImagedat(Bitmap);
            StringBuilder sb     = new StringBuilder(15000);

            SeetaFace.SixtyEightPoints(sid, sb);
            JsonSerializer serializer = new JsonSerializer();
            var            faces      = serializer.Deserialize <SeetaFace.Facepoints>(
                new JsonTextReader(
                    new StringReader(sb.ToString())
                    )
                );

            for (int i = 0; i < 68; i++)
            {
                Graphics g = Graphics.FromImage(Bitmap);
                Pen      p = new Pen(Color.Red);
                g.DrawEllipse(p, faces.Facepoint[0].points[i].x, faces.Facepoint[0].points[i].y, 5, 5);
            }
            pictureBox2.Image = Bitmap;
        }