2

I have a complex problem, I've been working on it for weeks. My program is an eduactional software which use the webcam for analyzing physical experiments (eg. oscillating movement). I've experienced the folowings:

  • If the processor is busy, the time measuring is inaccurate (ISampleGrabberCB.BufferCB(SampleTime))
  • If I don't use the time, just count the samples: 0, 1, 2... it looks better. I perceive this when I look at the curve of the movement.

My primary goal is reduce the inaccuracy, what I try to achieve with limitation of the FPS (which cause busy processor).

bsebi
  • 43
  • 1
  • 7

1 Answers1

1

from the MSDN article on Time and Clocks in DirectShow:

Any object that supports the IReferenceClock interface can serve as a reference clock. A filter with access to a hardware timer can provide a clock (an example is the audio renderer), or the filter graph manager can create one that uses the system time.

I've never attempted to use the IReferenceClock from a filter, but it would be my suspicion that it may not provide a high resolution clock that you need.

This SO post on high resolution timers might be what you need.

IAMStreamConfig.AvgTimePerFrame is for informational purposes, and attempting to adjust it won't have any effect. It's just a value from which you can calculate average frame rate for your video stream.

e.g.

VIDEOINFOHEADER* pVih = (VIDEOINFOHEADER*)m_MediaTypes.VideoType.pbFormat;

if( pVih )  
    int nFrameRate = (int)( (double) (10000000.0f / pVih->AvgTimePerFrame) );   
Community
  • 1
  • 1
  • Thanks for reply. I've tried different high resulotion timers, but this doesn't solve my problem. I need the accurate time of the sample, and it isn't help if I know the accurate time in an other moment. If I implement the IReferenceClock, and build it to my graph, it takes anything for me? (I think not, for the same reason) IAMStreamConfig.AvgTimePerFrame: You can change the AvgTimePerFrame's value, and it works for me with other webcams, but not with this. I have to optimalize my program to Intel Classmate PC, so I have to work with this hardware. – bsebi Dec 01 '10 at 15:22