示例#1
0
        private void DisplayNames(FaceData faceData)
        {
            StringBuilder names = new StringBuilder(faceData.ids.Length);

            foreach (var id in faceData.ids)
            {
                string name = Users.UsersData[id];
                names.Append(name);
            }

            this.nameLabel.Text = names.ToString();
        }
示例#2
0
        private void CaptureImage(object sender, EventArgs e)
        {
            Camera.GetFrame(delegate(Mat frame) {
                using (var currentFrame = frame.ToImage <Bgr, byte>())
                {
                    if (this.captureCheckBox.Checked)
                    {
                        _willSend = false;

                        string json = this.GetFaceJsonData(currentFrame);
                        if (json != null)
                        {
                            FaceData data = this.GetFaceData(json);
                            if (data != null && data.ids.Length > 0)
                            {
                                this.closingTimer.Start();

                                this.DisplayNames(data);
                                this.DrawRects(currentFrame, data.face_locations);

                                object attendanceData = new { ids = data.ids };
                                string jsonAttendance = JsonConvert.SerializeObject(attendanceData);

                                // Console.WriteLine(jsonAttendance);

                                MessageQueue.Send(MessageQueue.NodeJSClient, (int)Constants.RequestIntents.INTENT_REQ_UPDATE_ATTENDANCE_DATA, jsonAttendance);
                                MessageQueue.Receive(MessageQueue.NodeJSClient);
                            }
                            else
                            {
                                this.nameLabel.Text = "";
                            }
                        }
                    }
                    this.cameraCaptureImageBox.Image = currentFrame;
                }
            });
        }