none
Frame rate and polling RRS feed

  • Question

  • I'm confuse with frame rate and PC computational capability.

    1) The PC's computational capability affects the fps show in the SkeletalViewer example? -I say because of I read some forums and I don't understand clearly how the framerate.text acquire his value.

    2) I've read polling in MicrosogftGuide.pdf but I don't understand how to implement, could you give me a hand?

    3) If I need to save/write the data capture(RGD,Depth,Skeletal as stride), does this affect the polling?. There is way to do that (without affects the polling) -it's complex to programming or impossible for hardware-?

     

     

    Thanks

    sorry if I'm so impertinent, I'm new with C# and C++

    Thursday, August 11, 2011 8:32 PM

Answers

  • I'll answer your part (2) separately, since it's a question that has been asked a couple of times and usually I write code samples buried deeper within thread, so answering it directly will have a polling code sample close to top of thread. Note that this sample doesn't do any error checking and also blocks the thread being executed, so code structure would most likely be modified if it is to be integrated in a UI-driven application):

    HANDLE pVideoStreamHandle = NULL;
    
    NuiInitialize(NUI_INITIALIZE_FLAG_USES_COLOR);
    NuiImageStreamOpen(NUI_IMAGE_TYPE_COLOR,
        NUI_IMAGE_RESOLUTION_640x480,
        0,
        2,
        NULL,
        &pVideoStreamHandle);
    
    while (1)
    {
     const NUI_IMAGE_FRAME * pImageFrame = NULL;
     HRESULT hr = NuiImageStreamGetNextFrame(pVideoStreamHandle, 200, &pImageFrame);
     if( hr == E_NUI_FRAME_NO_DATA)
     {
     // No stream frame was found after waiting for requested amount.
     // Continue and try again (or, you could also choose to bail out
     // from function here).
     continue;
     }
     else if (FAILED(hr))
     {
     break;
     }
    
     // Your code to deal with data from pImageFrame
    
     NuiImageStreamReleaseFrame(pVideoStreamHandle, pImageFrame);
    }


    I'm here to help
    • Marked as answer by escorciav Friday, August 12, 2011 4:18 PM
    Thursday, August 11, 2011 9:59 PM

All replies

  • I'll answer your part (2) separately, since it's a question that has been asked a couple of times and usually I write code samples buried deeper within thread, so answering it directly will have a polling code sample close to top of thread. Note that this sample doesn't do any error checking and also blocks the thread being executed, so code structure would most likely be modified if it is to be integrated in a UI-driven application):

    HANDLE pVideoStreamHandle = NULL;
    
    NuiInitialize(NUI_INITIALIZE_FLAG_USES_COLOR);
    NuiImageStreamOpen(NUI_IMAGE_TYPE_COLOR,
        NUI_IMAGE_RESOLUTION_640x480,
        0,
        2,
        NULL,
        &pVideoStreamHandle);
    
    while (1)
    {
     const NUI_IMAGE_FRAME * pImageFrame = NULL;
     HRESULT hr = NuiImageStreamGetNextFrame(pVideoStreamHandle, 200, &pImageFrame);
     if( hr == E_NUI_FRAME_NO_DATA)
     {
     // No stream frame was found after waiting for requested amount.
     // Continue and try again (or, you could also choose to bail out
     // from function here).
     continue;
     }
     else if (FAILED(hr))
     {
     break;
     }
    
     // Your code to deal with data from pImageFrame
    
     NuiImageStreamReleaseFrame(pVideoStreamHandle, pImageFrame);
    }


    I'm here to help
    • Marked as answer by escorciav Friday, August 12, 2011 4:18 PM
    Thursday, August 11, 2011 9:59 PM
  • About 1), yes: if your computer doesn't have enough computational capacity available for image stream processing, your application will be able to fetch frames at a slower rate. computational capacity available is affected both by CPU speed, number of CPUs, total memory available and how much CPU and memory capacity are being used by other applications, or other components running under your own application.

    If you have enough computation capacity, or even capacity to spare, then you should see a fairly constant rate of 30 frames per second.

    3) If the remaining computation you need to do in your app takes less than approx 33 milliseconds per frame (1000 milliseconds in a second, divided by 30 frames per second), then things should be fine, and not affect your frame rate adversely.

    Hope this helps,
    Eddy


    I'm here to help
    Thursday, August 11, 2011 10:12 PM
  • Thanks Eddy.

    I've a new doubt about question 3.

    In other forum someone recommend me to use c++ & windows media foundation to save (Depth,Skeleton,RGB)-data but I'm new with C++ and C# (but C# is more easy to understand).

    Do you think that it's possible create a code to write (Depth,Skeleton,RGB)-data in 30 milliseconds?

    My intention doesn't bother but I appreciate so much if you recommend some tutorial or topics to make the code.

    Saturday, August 13, 2011 3:43 AM
  • You should definitely be able to write that data in 30 milliseconds or less. Someone posted a sample of writing bitmap data to file at bottom of thread http://social.msdn.microsoft.com/Forums/hr/kinectsdknuiapi/thread/5d904235-fedf-4bd3-ad8e-ba8d79e7aa36, and this topic is also discussed in thread http://social.msdn.microsoft.com/Forums/en-US/kinectsdknuiapi/thread/7a08ba0d-2b81-43a5-bba2-ca77b6d223a5.

    Eddy


    I'm here to help
    Monday, August 15, 2011 11:42 PM
  • Thanks Eddy, I checked some threads this weekend and I've started to read about Multithreading and files E/S to make my own code because I've a particular problem.

    I would like to receive your help in the future for "debug" my code (Obviously in other thread).

    Tuesday, August 16, 2011 9:54 PM