none
Latency and dropped frames RRS feed

  • Question

  • I'm new to C# and found the naive approach to coding bit me in the rump. I ran over the frame time by 1ms and since I wasn't making 30 fps WPF dropped my frame rate dynamically to 2-8 fps. So I added in instrumentation to see where my time went, optimized things a bit and got it down to 14ms per frame. As long as I was at it I thought I should count dropped frames and average latency.

    I found two problems. One is the frame number in the ImageFrame is advancing at a rate of 60 fps. There is no 60 frames to get though. Dropping out sections of my code I can drop my time in the event handler to under 4ms, low enough to sustain 60 fps. The other problem is the frame time is from an unknown time. The time starts during the call to Initialize, but that call takes nearly half a second to run. It seems to start within 50ms of that call, but it seems unlikely the actual latency is 50ms. There needs to be a way to synchronize to that timer.

    Sunday, July 17, 2011 6:19 AM

Answers

All replies

  • Investigating I found a way to measure the latency. I displayed the time down to the millisecond in big letters on the screen updated every millisecond. That drove the WPF frame rate to 90 FPS though the screen refresh rate is only 60hz. I also displayed the video stream off the camera and then pointed the camera at the screen. That gives me an image of the time displayed on the screen when the image was captured and the time of the frame displayed at that time. That gave about 114ms latency. That isn't accurate to the ms though since the screen is only updated every 1/60th of a second and a frame is only captured every 1/30th of a second. So perhaps 50ms is accurate for the latency to the start of the event handler.
    Sunday, July 17, 2011 9:02 PM
  • About the ImageFrame number advancing at a rate of 60fps instead of 30fps, this is a known issue that we're addressing.

    Eddy


    I'm here to help
    Monday, July 18, 2011 7:00 PM