示例#1
0
        //When the timer ticks the colorframe is polled and checked if there is a face
        private void OnTimerTick(object sender, ElapsedEventArgs e)
        {
            MultiSourceFrame multiSourceFrame = _multiSourceFrameReader.AcquireLatestFrame();

            if (multiSourceFrame != null)
            {
                using (ColorFrame colorFrame = multiSourceFrame.ColorFrameReference.AcquireFrame())
                {
                    if (colorFrame != null)
                    {
                        if (!_isEngaged)
                        {
                            NewEngagmentCheck(colorFrame);
                        }
                        else
                        {
                            StopEngagmentCheck(colorFrame);
                            if (_audioSource.IsRecording())
                            {
                                CheckStopRecording(colorFrame);
                            }
                            else
                            {
                                CheckStartRecording(colorFrame);
                            }


                            SendFaces(colorFrame);
                        }
                    }
                    else if (_isEngaged) //no color frame -> if engaged check not engagment
                    {
                        StopEngagmentCheck(null);
                    }
                }
            }
            else if (_isEngaged) //no frame -> if engaged check not engagment
            {
                StopEngagmentCheck(null);
            }
        }