Пример #1
0
        private void PlaybackStreaming_PlayByFrameIndex()
        {
            this.m_stopped = false;
            InitStreamState();



            switch (m_algoOption)
            {
            // 面部算法
            case AlgoOption.Face:
                this.faceModule = manager.QueryFace();
                if (faceModule == null)
                {
                    MessageBox.Show("QueryFace failed"); return;
                }

                InitFaceState();

                this.faceData = this.faceModule.CreateOutput();
                if (faceData == null)
                {
                    MessageBox.Show("CreateOutput failed"); return;
                }

                break;
            }

            if (manager.Init() < pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
#if DEBUG
                System.Windows.Forms.MessageBox.Show("init failed");
#endif
                return;
            }

            int nframes = manager.captureManager.QueryNumberOfFrames();
            MessageBox.Show(nframes + "");
            for (int i = 0;;)
            {
                if (m_pause)
                {
                    continue;
                }
                manager.captureManager.SetFrameByIndex(i);
                manager.FlushFrame();

                if (manager.AcquireFrame(true).IsError())
                {
                    break;
                }

                this.sample = manager.QuerySample();

                if (sample.depth != null)
                {
                    this.m_timestamp = (sample.depth.timeStamp);
                }
                else if (sample.color != null)
                {
                    this.m_timestamp = sample.color.timeStamp;
                }

                m_timestamp_sec = m_timestamp / 10000000;
                if (m_timestamp_sec_init == -1)
                {
                    m_timestamp_sec_init = m_timestamp_sec;
                }

                if (this.m_label != null)
                {
                    //updateLabel(this.m_timestamp.ToString());
                    System.Threading.Thread t1 = new System.Threading.Thread(updateLabel);
                    t1.Start((m_timestamp_sec - m_timestamp_sec_init).ToString());
                }

                if (m_display)
                {
                    this.DoRender();
                }

                manager.ReleaseFrame();

                if (this.m_playback_reverse)
                {
                    if (i <= this.m_playback_framespeed)
                    {
                        break;
                    }
                    i -= this.m_playback_framespeed;
                }
                else
                {
                    if (i >= nframes - this.m_playback_framespeed)
                    {
                        break;
                    }
                    i += this.m_playback_framespeed;
                }
            }

            faceData.Dispose();
            manager.Dispose();
        }