Save captured video frame as image files

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

DanielMeyer

  • Posts: 2
  • Joined: Thu Apr 28, 2016 1:33 pm
  • Location: Frankfurt, Germany

Save captured video frame as image files

PostThu Apr 28, 2016 2:02 pm

Hi,

Now, I have a nice DeckLink Studio 4K and trying to use it. I Chose CapturePreview project in Win>Samples path. I am currently studying Blackmagic Decklink SDK API manual and the codes of the CapturePreview project. Now, I almost know the program flow of the project. As I understand the
Code: Select all
videoFrame
argument in
Code: Select all
IDeckLinkInputCallback::VideoInputFrameArrived
method contains the captured video frame. Please guide me:

1. How can I save this captured video frame as an image file like tiff, jpeg, PNG?

2. How can I save this captured video frame in a determined place in buffer to use in MATLAB?

My situation:
I am using Windows7 x64 and VS2012. I connected input of my DecKLink card to HDMI output of my laptop.
I can run the CapturePreview project and get the screen of my laptop in priview window correctly.
Thanks.
Offline

MarkusPilen

  • Posts: 11
  • Joined: Mon Feb 08, 2016 4:15 pm

Re: Save captured video frame as image files

PostSat Apr 30, 2016 11:48 am

Hi Daniel,

Yes, the videoFrame argument represents a single video frame. It contains, among other stuff, the raw image data, which can be retrieved by
Code: Select all
void* data = NULL;
inputFrame->GetBytes(&data);


1. Using the above, you'll get the raw image data. The data format of course depends on your video format, but you should be able to find that information in the SDK documentation. How to save the frame to disk as an image is what Google is for :)
2. Well, if you want to do it live, you'll have to setup some kind of shared memory between the C++ process running the DeckLink code and the MATLAB process. If you can do it offline, then it might be easier to just save the video on your hard drive, either frame by frame or as a video, and then load it from there into MATLAB.

Hope it helps,
Markus
Offline

Dave Johnstone

  • Posts: 223
  • Joined: Mon Dec 08, 2014 11:12 am
  • Location: Adelaide

Re: Save captured video frame as image files

PostSun May 01, 2016 9:35 am

If your frame is RGB, then it can be saved, for example, as an uncompressed Targa file by simply adding the tga header before the image data. The header contains, amongst other things, the pixel mode (24-bit etc); image dimensions; image X-Y origin. Compressed formats would probably be best handled by an external library.

Regards,

Dave.
Freelance Television Broadcast Engineer
and Software Programmer.
Offline

DanielMeyer

  • Posts: 2
  • Joined: Thu Apr 28, 2016 1:33 pm
  • Location: Frankfurt, Germany

Re: Save captured video frame as image files

PostSun May 01, 2016 10:00 am

Hi,

I checked the format of my captured video frame by calling
Code: Select all
IDeckLinkVideoFrame::GetPixelFormat()
method. Its format was
Code: Select all
bmdFormat10BitYUV
. Is it possible to set parameters so that the device captures in a desired format such as RGB?
According to MarkusPilen's answer I am searching in google to find a good document to describe a solution for converting 10BitYUV to image file formats (JPG, PNG, ...). But I could not find a complete reference yet.
Does anybody have a good reference?
Thanks.

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 27 guests