Page 1 of 1

Sample C++ code not working

PostPosted: Sun Jun 07, 2015 9:50 am
by Rick Jansen
Dear,

I am new to the Blackmagic SDK so I tried the sample code in C++. All the projects are giving the message "A DeckLink iterator could not be created. The DeckLink drivers may not be installed.". When looking more into the code the message appears because the Iterator cannot be created. At the line:
result = CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL, IID_IDeckLinkIterator, (void**)&pDLIterator);

VS2010 is giving the message:
result = 0x80040154 Class not registered

CLSID_CDeckLinkIterator has an GUID
IID_IDeckLinkIterator has an GUID

Also when I tried to create a new project in VS2010, added the IDL, compiled it, added the .C file. It still not works. The Decklink driver are installed and working (tested via Directshow) Am I doing something wrong? Or did I missed something?

Re: Sample C++ code not working

PostPosted: Thu Jun 25, 2015 6:23 pm
by Matt Jefferson
HI Rick

Just getting a chance to see if you had any success here with your application development. I saw no updates so wondering which version of desktop SDK you are using and which product.

We moved to VS2013 with release of 10.4 SDK so it is best to compile and test against it. Also, it always helps others on forum to know your basics like which product, which driver, (assume windows OS based on post), does any of the samples based on SDK work for you (recommend signal generator and capture preview) which are in the win samples bin folder under the Win OS SDK Folder.
Matt Jefferson

Re: Sample C++ code not working

PostPosted: Mon Aug 24, 2015 7:29 pm
by Rick Jansen
Hi Matt,

A small add to my question. The C# example code is working fine on the same system.

The Blackmagic card I use is one of the first generations SDI cards with an breakout cable. As you suggested I tried the Signal Generator project example.

Rick

Re: Sample C++ code not working

PostPosted: Thu Sep 17, 2015 3:14 am
by Koo Tai
Same problem here.
When goto the line
hr = CoCreateInstance(clsid, 0, CLSCTX_INPROC_SERVER, IID_IBaseFilter, reinterpret_cast<void**>(&pFilter)),
hr got the error 0x80040154 Class not registered.
It's also failed even I tried the sample exe file under the bin folder.
I am testing the DirectShow DecklinkKey example and I am using DeckLink SDI 4K.

Re: Sample C++ code not working

PostPosted: Wed Sep 30, 2015 5:09 pm
by Ed Dow
Greetings All,

Card: Decklink 4K Extreme 12G
Platform: Windows 7
Environment: VC++ 2012

Here's the smoking gun that the SDK documentation fails to mention for us poor souls that are new to all this sort of programming.

// create result container
HRESULT result;

// create pointer to deckLinkIterator object
IDeckLinkIterator *deckLinkIterator = NULL;

// initialize the instance -- this is what's missing
CoInitializeEx(NULL, COINIT_MULTITHREADED);

// now you can create the instance of the deckLinkIterator
result = CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL, IID_IDeckLinkIterator, (void**)&deckLinkIterator);


Now, someone please tell me how to not get linker errors when building my project?

This is what I'm getting:
error LNK2001: unresolved external symbol "public: virtual unsigned long __cdecl DeckLinkCaptureDelegate::AddRef(void)" (?AddRef@DeckLinkCaptureDelegate@@UEAAKXZ)

I don't understand what is going on here? Normally I could just add a .lib file under the Linker tab and that would resolve all the issues. But it seems that there are no .lib files to add?

I've build the .idl file and have included the .h and .c in my project. I had the issue with using pre-compiled headers but resolved that. Now I'm stuck?

Re: Sample C++ code not working

PostPosted: Thu Oct 01, 2015 1:50 am
by Nicholas Gill
Hi All,

CoInitialize [1] / CoInitializeEx [2] must be called in order to initialise COM. This is not part of, nor specific to, the DeckLink SDK.

This can be observed in the SDK samples, e.g in Win\Samples\CapturePreview\CapturePreview.cpp.

One other possible cause of the "Class not registered" error as mentioned is if a newer SDK is used than the drivers installed.

It is always possible to use an older SDK with a newer driver, however it is not recommended to use a newer SDK with an older driver as the SDK will assume the presence of features / interfaces which may not have existed in the older driver.

@Ed: The linker error mentioned is not related to the DeckLink API. Despite the name "DeckLinkCaptureDelegate" is a user type and not an API class or function. Perhaps you've copied a declaration from the Linux 'Capture' sample and not implemented it?

Cheers,

-nick

[1] https://msdn.microsoft.com/en-us/librar ... 43(v=vs.85).aspx
[2] https://msdn.microsoft.com/en-us/librar ... 79(v=vs.85).aspx

Re: Sample C++ code not working

PostPosted: Thu Oct 01, 2015 6:14 pm
by Ed Dow
Greetings All,

@Nick -- This is exactly what I've done as I'm trying to port the Linux sample Capture program to Windows. I know there is a windows sample but I need a simple console app that can be called from the command line. I know it can be done as I did a few years back but I can't find my code.

To your point about copying the declaration but not implementing it, yes. This is my thought too, although I just don't know where to go from here. So let's just looks at what I'm seeing and try to make some sense out of it:

I have the following:

I get the link error as soon as I try to include what I believe is the implementation? I had a similar issue with pthread. I was able to resolve this by telling the linker to use a particular .lib file. However, with the SDK there is no .lib file to link to. Thoughts?


consoleApp.cpp -- this is my main app
#include capture.h
#include "DeckLinkAPI_h.h"

capture.h -- this is where the declaration is at
#include "DeckLinkAPI_h.h"

class DeckLinkCaptureDelegate : public IDeckLinkInputCallback
{
public:
DeckLinkCaptureDelegate();



capture.cpp -- this is where the implementation should reside at
#include capture.h
#include "DeckLinkAPI_h.h"


DeckLinkCaptureDelegate::DeckLinkCaptureDelegate() : m_refCount(0)
{
pthread_mutex_init(&m_mutex, NULL);
}

Re: Sample C++ code not working

PostPosted: Thu Oct 01, 2015 7:54 pm
by Ed Dow
Greetings All,

OK so I've got past the linker issue. It was an implementation issue. Not sure what was going on with the headers and implementation files but I ripped it out and just put it in the main program. I can get all fancy later with header files and stuff.

I'll keep you all updated.

Re: Sample C++ code not working

PostPosted: Fri Oct 02, 2015 5:55 pm
by Ed Dow
Greetings All,
I should like to say that I've successfully ported the Linux capture sample app to Windows. However, I haven't been able to verify the video content is good.

The program dumps out in RAW format. mplayer for Windows produces strange green video.

Anyone know of other RAW media players?

Anyone got other suggestions?

Re: Sample C++ code not working

PostPosted: Mon Oct 05, 2015 5:40 pm
by Ed Dow
Greetings All,
I can capture UHD @30fps.
Mplayer played captured content but lots of green and pink frames throughout the video.
Initially when I started using the card Media Express was producing a similar result until I upgraded.

Decided to dump RAW frames to see if that would shed any light on this issue. Same issue seen in frames that are dumped. (see attached pic)
DeckLink4KExtreme12G_CapApp.jpg
notice how half of the frame looks good
DeckLink4KExtreme12G_CapApp.jpg (52.44 KiB) Viewed 8507 times



Media Player seems to capture fine.

I'm still suspicious of mplayer so if anyone knows of any other RAW video players lets hear about them.

However on the suspicious note should I have any concerns that it could be software and firmware not playing nice together?

Ideas?

Ed

Re: Sample C++ code not working

PostPosted: Fri Oct 09, 2015 5:21 pm
by Ed Dow
Greetings All,

Wow, tough crowd. I still haven't found much and still have the green frames with the .raw video.

I did manage to convert video to OpenCV format and dump JPEG frames. There's something goofy with the conversion because the pictures look as though they've been sliced together.

Ed

Re: Sample C++ code not working

PostPosted: Wed Oct 14, 2015 5:03 pm
by Ed Dow
Greetings All,
OK...so I figured out the conversion. I can dump full frames of video.

However, the time that it takes to convert and dump the frames of video is costing me time so I don't get every frame.

Of course my original intent is all about capturing video via the command line. With the sample code and some other code I found I can:

1) capture raw video
2) capture frames of video

I still don't have a way to play back the raw video accurately. If anybody comes across a good player post please.

Re: Sample C++ code not working

PostPosted: Tue May 01, 2018 3:33 pm
by antithing
@Ed_Dow, Hi! Sorry to bump such an old thread. I am trying, and failing to get frames from my decklink into opencv format. Did you manage to solve this? Are you able to share your solution? Thanks!