Dear all, I am using SampleGrabberCB.BufferCB to capture frames from a framegrabber. My problem is that the processing I am performing takes more than 40ms and so I have to skip some frames in order to maintain a real-time on the video feed. As far as I have understood, this method always acquire a frame every time it is ready on the framegrabber even if you put a sleep in the function itself. Is there a way to skip a frame? I tried to Pause and Run again the graph but it takes too much time. Any suggestions? Thank you Guido
On Jun 25, 10:01 am, Odisseo wrote: > Dear all, > I am using SampleGrabberCB.BufferCB to capture frames from a > framegrabber. > > My problem is that the processing I am performing takes more than > 40ms > ... > Is there a way to skip a frame? You get BufferCB on every frame, you can't put it to sleep, this will delay your sample grabber....you may try using a counter variable for measuring time between last frame processing, if it's lower than a time you set, you just don't perform the processing and exit the callback.
From: "Odisseo" > My problem is that the processing I am performing takes > more than 40ms > and so I have to skip some frames in order to maintain a > real-time on the video feed. > As far as I have understood, this method always acquire a > frame every time it is ready on the framegrabber even if > you put a sleep in the function itself. > Is there a way to skip a frame? > I tried to Pause and Run again the graph but it takes too > much time. You can not use the stock SampleGrabber if your processing is not synchronous. You need to write your own filter based on CBaseFilter + CBaseInputPin + CBaseOutputPin. You filter spawns a worker thread (that can optionally be based on CAMThread or CAMMsgThread). The thread waits for a sample to arrive (you can optionally use CAMEvent or CAMMsgEvent), then processes it and delivers it downstream through the output pin. When your input pin receives a sample, it checks whether the thread is waiting or processing: if the thread is waiting, it signals the thread to start processing the new sample, otherwise it discards the sample. -- // Alessandro Angeli // MVP :: DirectShow / MediaFoundation // mvpnews at riseoftheants dot com // http://www.riseoftheants.com/mmx/faq.htm
Thank you Alessandro for your reply. Your solution seems to fit to my requirements. Do you have any example you could provide me? Thank you Guido
From: "Odisseo" > Your solution seems to fit to my requirements. > Do you have any example you could provide me? No, I don't have a sample which does that. -- // Alessandro Angeli // MVP :: DirectShow / MediaFoundation // mvpnews at riseoftheants dot com // http://www.riseoftheants.com/mmx/faq.htm