get bytes of a frame using csharp without using events

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline

tomsap

  • Posts: 19
  • Joined: Tue Mar 03, 2020 4:17 pm
  • Real Name: Tom Saplonsky

get bytes of a frame using csharp without using events

PostThu Aug 13, 2020 1:39 pm

Hello everyone,

I'm using c# with the example program that in the SDK folder that called csharpstills.
I have seen that this example used events when a frame is arrived.
My question is if there is a way that my blackmagic 4k extreme can display frames all the time and I will read the value of the frames (the bytes) without using events in my code when I want to.
My motivation for this is that I want to create a simple program (in c#) that only reads the bit values that the card samples in real time without events and windows for application.

Thanks,

Tom.
Offline

Cameron Nichols

Blackmagic Design

  • Posts: 443
  • Joined: Mon Sep 04, 2017 4:05 am

Re: get bytes of a frame using csharp without using events

PostThu Aug 13, 2020 11:38 pm

Hi Tom,

The motivation for using EventHandler in StillsCSharp is to move the processing of IDeckLinkVideoConversion and Bitmap.Save out of DeckLinkInputCallback.VideoInputFrameArrived callback context and into its own invoked method.

You can move this processing back into the callback. Take care however, you should be conscious of the processing time in the callback. If this time is on average longer than the frame rate period, then you will eventually see dropped frames as the input video frame buffer allocator becomes exhausted due to queued frames.

Regards
Cameron
Offline

tomsap

  • Posts: 19
  • Joined: Tue Mar 03, 2020 4:17 pm
  • Real Name: Tom Saplonsky

Re: get bytes of a frame using csharp without using events

PostSat Aug 15, 2020 9:06 am

Hi Cameron,

Thank you for your replay.
If I understand correctly, the DeckLinkInputCallback.VideoInputFrameArrived method that in DeckLinkInputDevice class is activated every time that a frame arrives? If this is true, where can it be seen in the code?

Thanks,
Tom
Offline

Cameron Nichols

Blackmagic Design

  • Posts: 443
  • Joined: Mon Sep 04, 2017 4:05 am

Re: get bytes of a frame using csharp without using events

PostSun Aug 16, 2020 11:07 am

Hi Tom,

Yes, IDeckLinkInputCallback.VideoInputFrameArrived callback is called for every received frame.

To highlight implementation of StillsCSharp:
  1. DeckLinkInputDevice class implement interface IDeckLinkInputCallback. This interface defines 2 callbacks: IDeckLinkInputCallback.VideoInputFrameArrived and IDeckLinkInputCallback.VideoInputFormatChanged, both are implemented.
  2. The implemented IDeckLinkInputCallback class is registered to a IDeckLinkInput, by calling IDeckLinkInput.SetCallback (in StartCapture method).
  3. The end of IDeckLinkInputCallback.VideoInputFormatChanged signals event VideoFrameArrivedHandler. The Stills class has registered to this event handler in ToggleCapture method.
  4. The event subscriber is a lambda calling Invoke, hence puts the frame processing in asynchronous task calling method VideoFrameArrived.

Regards
Cameron
Offline

tomsap

  • Posts: 19
  • Joined: Tue Mar 03, 2020 4:17 pm
  • Real Name: Tom Saplonsky

Re: get bytes of a frame using csharp without using events

PostMon Aug 17, 2020 6:05 pm

Hi Cameron,

Thank you for your detailed answer!
I return back to my initial motivation, I need to build a program that will only take the bit values of the current frame that my blackmagic 4k extreme gets.
Could there be a simpler solution than the solution that presented in the StillsCSharp example for only gets these values?

Thanks,
Tom.

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 17 guests