我是一名电气工程专业的学生,在我实习的第一个代码,我必须写一些东西,从DeckLink Duo 2卡捕获和保存图像和视频,只使用SDK,这是我的第一个"真正的代码",不像我们在大学写的最基本的东西。
在这一点上,我已经尝试了一个多星期来理解如何使用那个SDK,但并没有取得很大的成功。更具体地说,我一直试图遵循文档的第19页和第20页,试图一次写一个方法,但仍然卡在第一个。
我的想法,这似乎是在SDK给出的例子的情况下,是实现类作为指针,然后使用它们执行建议的方法,如在下面的代码。我只是试着调用EnableVideoInput方法通过确保我实现了其中一个,我知道实现其他的路径:
#include "DeckLinkAPI.h"
#include <stdio.h>
#include <list>
#include <map>
#include <conio.h>
#include "platform.h"
int main(int argc, char** argv)
{
IDeckLink* deckLink;
IDeckLinkIterator* deckLinkIterator;
IDeckLinkInput* deckLinkInput;
IDeckLinkDisplayMode* displayMode;
HRESULT result;
// Initialize COM on this thread
result = CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (FAILED(result))
{
fprintf(stderr, "Initialization of COM failed - result = %08x.n", result);
return 1;
}
// Comando CoCreateInstance orientado pela documentacao para criar o objeto iDeckLink.
result = CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL, IID_IDeckLinkIterator, (void**)&deckLinkIterator);
if (result != S_OK)
{
fprintf(stderr, "The selected device does not have an input interfacen");
}
// Applying the step suggested in the documentation
result = deckLinkInput->EnableVideoInput(bmdModeHD1080p6000, bmdFormat8BitYUV, bmdVideoInputFlagDefault);
CoUninitialize();
getch();
}
它构建,但是当我尝试打开或调试它时,它说"变量'deckLinkInput'正在使用而未初始化"。我错了什么,我怎么能实现这些方法?
编译器是正确的,deckLinkInput
未初始化,您忘记调用IDeckLinkIterator::Next
来获取卡片:
result = deckLinkIterator->Next(&deckLink);
然后您需要从卡片中获取输入:
result = deckLink->QueryInterface(IID_IDeckLinkInput, (void**)&deckLinkInput);