Esempio n. 1
0
        private void updateGUI()
        {
            // Display image
            if (m_width > 0 && m_height > 0)
            {
                if (s_buffer1 == null)
                {
                    var format = PixelFormats.Bgra32;
                    windowBuffer1 = new WriteableBitmap(m_width, m_height, 0, 0, format, BitmapPalettes.Gray256);
                    s_buffer1     = new byte[(int)m_numChannels * m_width * m_height];
                    image1.Source = windowBuffer1;
                    windowBuffer2 = new WriteableBitmap(m_width, m_height, 0, 0, format, BitmapPalettes.Gray256);
                    s_buffer2     = new byte[(int)m_numChannels * m_width * m_height];
                    image2.Source = windowBuffer2;
                }
                //try
                //{
                if (videoFile.playMode)  // && Fubi.isPlayingSkeletonData())
                {
                    frameNr = videoFile.readFrame(s_buffer1, frameNr);
                    var stride1 = windowBuffer1.PixelWidth * (windowBuffer1.Format.BitsPerPixel / 8);
                    windowBuffer1.WritePixels(new Int32Rect(0, 0, windowBuffer1.PixelWidth, windowBuffer1.PixelHeight), s_buffer1, stride1, 0);
                }
                //}
                //catch (Exception ex)
                //{
                //    MessageBox.Show(ex.ToString());
                //}

                var stride2 = windowBuffer2.PixelWidth * (windowBuffer2.Format.BitsPerPixel / 8);
                //int c = BitConverter.ToInt32(s_buffer2, (stride2 * windowBuffer2.PixelHeight+ stride2)/2);  //sample center
                //Console.WriteLine(c.ToString("x"));  // seems to be ARGB format as printed (ie byte reverse)
                s_buffer2 = videoFile.edgeFilter(s_buffer2);
                windowBuffer2.WritePixels(new Int32Rect(0, 0, windowBuffer2.PixelWidth, windowBuffer2.PixelHeight), s_buffer2, stride2, 0);
            }
        }
Esempio n. 2
0
        private void updateGUI()
        {
            // Display image
            if (m_width > 0 && m_height > 0)
            {
                if (s_buffer1 == null)
                {
                    var format = PixelFormats.Bgra32;
                    windowBuffer1 = new WriteableBitmap(m_width, m_height, 0, 0, format, BitmapPalettes.Gray256);
                    s_buffer1     = new byte[(int)m_numChannels * m_width * m_height];
                    image1.Source = windowBuffer1;
                    windowBuffer2 = new WriteableBitmap(m_width, m_height, 0, 0, format, BitmapPalettes.Gray256);
                    s_buffer2     = new byte[(int)m_numChannels * m_width * m_height];
                    image2.Source = windowBuffer2;
                }
                //try
                //{
                if (videoFile.playMode && !stopDepthVideo)  // && Fubi.isPlayingSkeletonData())
                {
                    frameNr = videoFile.readFrame(s_buffer1, frameNr);
                    var stride1 = windowBuffer1.PixelWidth * (windowBuffer1.Format.BitsPerPixel / 8);
                    windowBuffer1.WritePixels(new Int32Rect(0, 0, windowBuffer1.PixelWidth, windowBuffer1.PixelHeight), s_buffer1, stride1, 0);
                }
                //}
                //catch (Exception ex)
                //{
                //    System.Windows.MessageBox.Show(ex.ToString());
                //}

                var stride2 = windowBuffer2.PixelWidth * (windowBuffer2.Format.BitsPerPixel / 8);
                //int c = BitConverter.ToInt32(s_buffer2, (stride2 * windowBuffer2.PixelHeight+ stride2)/2);  //sample center
                //Console.WriteLine(c.ToString("x"));  // seems to be ARGB format as printed (ie byte reverse)
                if (filterActive)
                {
                    s_buffer2 = videoFile.edgeFilter(s_buffer2);
                }
                windowBuffer2.WritePixels(new Int32Rect(0, 0, windowBuffer2.PixelWidth, windowBuffer2.PixelHeight), s_buffer2, stride2, 0);
            }

            userStatsLbl.Content = numUsers.ToString();
            if (gestureStep)
            {
                gestureStep = false;
                setProgress(gameStage + 1);
            }
            else if (!userVisible && gameStage > 0)
            {
                setProgress(0);  // return to start
            }
            else if (gameStage > 0)
            {
                double stage_time = (DateTime.Now - stageTime).TotalSeconds;
                if (stage_time > stageTimeLimit)
                {
                    if (testMode == 0)
                    {
                        if (gameStage > 6)
                        {
                            setProgress(0);  // fail notice should appear if gamestage > 0 and user still present
                        }
                        else
                        {
                            setProgress(8);  // note that stage 7 is the success stage
                        }
                    }
                    else
                    {
                        TimeOutBar.Width = 0;
                    }
                }
                else if (gameStage > 0)
                {
                    TimeOutBar.Width = stage_time / stageTimeLimit * progressStackPanel.ActualWidth;
                }
                else
                {
                    TimeOutBar.Width = 0;
                }
            }

            if (statusMessage.Length > 0)  // used in test modes
            {
                statusLbl.Content    = statusMessage;
                statusLbl.Visibility = Visibility.Visible;
                statusMessage        = "";
            }

            if (!videoPlaying)
            {
                videoPlaying = true;
                mvPlaying    = true;
                maleSpiderVideo.Play();
                if (secondWindow)
                {
                    fvPlaying = true;
                    window1.femaleSpiderVideo.Play();
                }
            }
        }