none
Does ColorImageFrame.FrameNumber works? RRS feed

  • Question

  • Hi, I have a question during programming Kinect Apps in c#.

    Does FrameNumber and Timestamp , properties of ColorImageFrame, works?

    Actually, I made a simple App to count the frames and timestamp in Fab. 2012. and It worked at that day.

    But now, It doesn`t work like this

    some strange numbers are included in FrameNumber and Timestamp soon after debuging this app.

    I just put the code like this.

    void FramePerSecond(ColorImageFrame imageFrame)
            {
                textBlock1.Text = imageFrame.FrameNumber.ToString();
                textBlock2.Text = imageFrame.Timestamp.ToString();

    Thanks in advance!

    Monday, July 23, 2012 7:48 AM

Answers

  • The FrameNumber property is simply a unique number that identifies the frame. It increases with each frame, but it doesn't necessarily increase by 1 each time (it might increase by more).

    The Timestamp property gives you a time value, in milliseconds representing when the frame was captured by the sensor. The absolute value of TimeStamp has no meaning, but the relative values from frame-to-frame will tell you how much time elapsed between the frames.

    Are you just trying to determine the frame rate? If so, you should be able to use the reciprocal of the difference between the current frame's timestamp and the previous frame's timestamp:

    long lFramesPerSecond = 0;
    long lTimestamp = imageFrame.Timestamp;
    if (m_lPrevTimestamp != 0)
    {
        lFramesPerSecond = 1000 / (lTimestamp - m_lPrevTimestamp);
    }
    m_lPrevTimestamp = lTimestamp;
    
    This will give you the instantaneous frame rate, which could be noisy. If you want a more stable rate, you might want to change the code to maintain a running average.


    John | K4W Dev

    Friday, August 3, 2012 7:07 PM

All replies

  • Can you please be more specific about the "strange numbers"? In what way are they strange?

    John
    K4W Dev

    Monday, July 30, 2012 11:28 PM
  • Thanks for reply!

    That Picture is first frame of the Stream. As you can see, Framecount(Red Text) is 29208, not 1. and Timestamp is 25547478.

    Those values increased continuously.  

    I just wondered how I can figure it out.

    Thanks for concerning!

    Wednesday, August 1, 2012 3:14 PM
  • The only guarantee about the values of the frame numbers is that they will increase over time. The specific values of individual frame numbers are not meaningful. If you need to maintain a frame count, you should do that for yourself in the appropriate event handler.


    John K4W Dev

    Thursday, August 2, 2012 4:54 PM
  • Okay. I understand.

    Actually I inserted the method to detect the average frame number in ColorFrameReady Event. 

    Here is my code.

    long m_lSaveTime = 0 ;
            long m_lSaveFrame = 0;
    
            void FramePerSecond(ColorImageFrame imageFrame)
            {
                textBlock1.Text = imageFrame.FrameNumber.ToString();
                textBlock2.Text = imageFrame.Timestamp.ToString();
    
                long lFrame = (long)imageFrame.FrameNumber;
                long lTime = (long)imageFrame.Timestamp;
                long lRes = (lFrame * 1000) / (lTime == 0 ? lFrame : lTime);
                textBlock3.Text = lRes.ToString();
    
                if (lTime - m_lSaveTime > 1000)
                {
                    long lTemp = lFrame - m_lSaveFrame;
                    textBlock4.Text = lTemp.ToString();
    
                    m_lSaveTime = lTime;
                    m_lSaveFrame = lFrame;
                }
            }

    If My code is right, text3(under the red text) show the average. But in the picture, always 1..

    In the past using K4W SDK v1.0, It worked fine. but in v1.5. weird value is shown on the screen.

    And there are no explanation about Framenumber and Timestamp of ColorImageFrame in MSDN.

    Could I ask you what those values means?

    Thanks!

    Friday, August 3, 2012 2:24 AM
  • The FrameNumber property is simply a unique number that identifies the frame. It increases with each frame, but it doesn't necessarily increase by 1 each time (it might increase by more).

    The Timestamp property gives you a time value, in milliseconds representing when the frame was captured by the sensor. The absolute value of TimeStamp has no meaning, but the relative values from frame-to-frame will tell you how much time elapsed between the frames.

    Are you just trying to determine the frame rate? If so, you should be able to use the reciprocal of the difference between the current frame's timestamp and the previous frame's timestamp:

    long lFramesPerSecond = 0;
    long lTimestamp = imageFrame.Timestamp;
    if (m_lPrevTimestamp != 0)
    {
        lFramesPerSecond = 1000 / (lTimestamp - m_lPrevTimestamp);
    }
    m_lPrevTimestamp = lTimestamp;
    
    This will give you the instantaneous frame rate, which could be noisy. If you want a more stable rate, you might want to change the code to maintain a running average.


    John | K4W Dev

    Friday, August 3, 2012 7:07 PM
  • Okay. I`ll try!

    Thanks for inspiring me!

    Saturday, August 4, 2012 1:45 AM