0

I'm looking for an example of how to create a circular buffer using MediaCapture to record seconds before a trigger and after, something similar to Raspberry Pi's picamera.PiCameraCircularIO(camera, seconds=clip_length).

I am creating a UWP app, which uses a USB camera and excepts a trigger, but I would like to have the Pre and Post timer around the trigger.

Jacob
  • 77,566
  • 24
  • 149
  • 228
Chris
  • 27
  • 7

1 Answers1

0

You need to implement a queue to store frames in it. Think you have one feame per second then you need queue of frames to store before and after triger specific seconds.

For example you need 15 seconds before and after the trigger.

In your queue you add image of each second to the queue and check when the queue got full (in this case 15 frames) dequeu one item and add new frame to queue. By this way you always have 15 frames before event got triggered. I think the next 15 frames after triggering event is simple enough ;)

Mojtaba Tajik
  • 1,725
  • 16
  • 34
  • Thanks for your reply, I was thinking something like that but i'm not sure how to achieve with MediaCapture? any examples would be appreciated. thanks – Chris Sep 10 '18 at 11:50
  • I have found a way to get the MediaFrames but now really don't know how to group them and then save to a file? – Chris Sep 10 '18 at 14:51
  • @Chris Have you checked this https://stackoverflow.com/a/46316765/6782612 to see if it's that you want? – Xie Steven Sep 18 '18 at 06:24
  • Thanks @XavierXie-MSFT. It's not quite what I'm looking for but was an interesting read. I have opted for a different solution similar to what you have posted using two clips running side by side. Not entirely what I wanted and not as clear as the piCameraCircularIO that python/raspberry pi use – Chris Oct 08 '18 at 10:08