Page 1 of 1

OpenCV Tutorial Source Code

PostPosted: Wed May 08, 2019 11:42 pm
by jmeldrum
I appreciate the video tutorial for live video processing with OpenCV that was posted recently on the Support page. Is the full source code available for the tutorial?

Re: OpenCV Tutorial Source Code

PostPosted: Sun Sep 29, 2019 11:09 pm
by GlennNZ
+1
Me to!
Thanks

Re: OpenCV Tutorial Source Code

PostPosted: Tue Mar 17, 2020 10:59 am
by tautin
For what it's worth, +1 ;)

Re: OpenCV Tutorial Source Code

PostPosted: Wed Mar 18, 2020 10:19 pm
by Cameron Nichols
Hi Tim,

The Live Video Processing with OpenCV tutorial source is available on the Blackmagic Developer site:

https://www.blackmagicdesign.com/develo ... d-playback

Under heading: Presentations and Sample Code

Regards
Cameron

Re: OpenCV Tutorial Source Code

PostPosted: Fri Mar 20, 2020 3:26 pm
by tautin
Hi Cameron,

Thank you so much :)!
I ran the program and would like to know if there's something we can do to improve the latency when simply looping through, or this the best we can get with Decklink cards (I'm evaluating AR directly with Decklink vs with ATEM + green background / keying)?

Thanks again!

EDIT: you might want to know that the code requires some minor updates to run with a DeckLink 8K Pro.

Re: OpenCV Tutorial Source Code

PostPosted: Fri Jul 10, 2020 1:56 pm
by giorgi3092
tautin wrote:Hi Cameron,

Thank you so much :)!
I ran the program and would like to know if there's something we can do to improve the latency when simply looping through, or this the best we can get with Decklink cards (I'm evaluating AR directly with Decklink vs with ATEM + green background / keying)?

Thanks again!

EDIT: you might want to know that the code requires some minor updates to run with a DeckLink 8K Pro.


Hey, can you elaborate on what changes are required to run the OpenCV example with DeckLink 8K Pro?
I am having trouble running it. The output is:
Code: Select all
StartDeckLinkCapture
Capture failed: Could not enable video input


I examined the code quickly and have set the mode to bmdModeHD1080i50 as the camera connected is set to 1080i50 as SDI video output.
I get the same error when I run the program.

I also ran the sample programs which auto-detect the camera mode and they also choose this mode (bmdModeHD1080i50) automatically.

But, again, I can't get it to work with the given OpenCV example.

Can you help on this?

Re: OpenCV Tutorial Source Code

PostPosted: Thu Jul 16, 2020 3:45 pm
by tautin
Hey, can you elaborate on what changes are required to run the OpenCV example with DeckLink 8K Pro?
I am having trouble running it. The output is:


Hello,

I don't remember what I changed exactly, but I attached the working project (tested on Ubuntu 16.04 LTS with a DeckLink 8K Pro).

Step I followed:
- plug your camera in the 1st input (the one next to the ref input)
- plug your screen in the 3rd input
- open BlackMagic Desktop Video Setup and:
-> set DeckLink 8K Pro (1) connector to SDI 1 In or Out
-> set DeckLink 8K Pro (2) connector to SDI 3 In or Out
- update the BuildLinux.sh script to put your OpenCV & DeckLink SDK paths
- update the LiveVideoWithOpenCV.cpp at line 552 to set your camera's video mode (4K, Full HD, etc)
- cd into the project folder
- run ./BuildLinux.sh
- run ./build/LiveVideoWithOpenCV

By default you should get a video with a green rectangle around your face when you smile.

Have fun ;)

Re: OpenCV Tutorial Source Code

PostPosted: Mon Jul 20, 2020 8:19 am
by giorgi3092
tautin wrote:
Hey, can you elaborate on what changes are required to run the OpenCV example with DeckLink 8K Pro?
I am having trouble running it. The output is:


Hello,

I don't remember what I changed exactly, but I attached the working project (tested on Ubuntu 16.04 LTS with a DeckLink 8K Pro).

Step I followed:
- plug your camera in the 1st input (the one next to the ref input)
- plug your screen in the 3rd input
- open BlackMagic Desktop Video Setup and:
-> set DeckLink 8K Pro (1) connector to SDI 1 In or Out
-> set DeckLink 8K Pro (2) connector to SDI 3 In or Out
- update the BuildLinux.sh script to put your OpenCV & DeckLink SDK paths
- update the LiveVideoWithOpenCV.cpp at line 552 to set your camera's video mode (4K, Full HD, etc)
- cd into the project folder
- run ./BuildLinux.sh
- run ./build/LiveVideoWithOpenCV

By default you should get a video with a green rectangle around your face when you smile.

Have fun ;)


Thank you so much! I am developing on Windows but your modifications immensely helped me to gain insight into the flow of the program and what functions really do.

I have modified the DeviceManager class according to yours and it works now!
The problem was that the program only kept enabling the device which arrived last, which was DeckLink subdevice 4 which was not correctly configured in Video Setup software. Your code kept those device pointers in an array and enabled me to enable each device separately and choose the device properly.

Also, credits to Cameron Nichols who gave me valuable insight through email exchange.
Thanks!

Re: OpenCV Tutorial Source Code

PostPosted: Wed Dec 02, 2020 3:26 pm
by HEILMAO
Hi all,

I have been trying to get the Decklink Quad 2 capture card to stream video footage. The issue I am having sounds very similar to the one above. When I run the OpenCV sample code you have mentioned above, I get the same error:
Code: Select all
StartDeckLinkCapture
Capture failed: Could not enable video output

I have then modified the program with the mentioned steps (I am using Windows 10 so I did the Windows equivalent for building the code):
- plug your camera in the 1st input (the one next to the ref input)
- plug your screen in the 3rd input
- open BlackMagic Desktop Video Setup and:
-> set DeckLink 8K Pro (1) connector to SDI 1 In or Out
-> set DeckLink 8K Pro (2) connector to SDI 3 In or Out
- update the BuildLinux.sh script to put your OpenCV & DeckLink SDK paths
- update the LiveVideoWithOpenCV.cpp at line 552 to set your camera's video mode (4K, Full HD, etc)
- cd into the project folder
- run ./BuildLinux.sh
- run ./build/LiveVideoWithOpenCV

After I make these changes and use the provided code in the zip file attached above, I get the following error when building:
Code: Select all
C:\Users\...\DeviceManager.h(80,35): error C3861: 'CreateDeckLinkDiscoveryInstance': identifier not found [C:\Users\...\build\LiveVideoWithOpenCV.vcxproj]

The location pointed to is the following line of code:
Code: Select all
m_decklinkDiscovery = CreateDeckLinkDiscoveryInstance();

I am not sure what I should be doing here. giorgi3092 are you able to elaborate on what you did at this stage? If you require any additional information I am happy to provide. Thank you for your help!

Re: OpenCV Tutorial Source Code

PostPosted: Fri Dec 04, 2020 4:21 am
by Cameron Nichols
Hi Oliver,

If I can point you to a segment of code in the Live Video with OpenCV sample, in DeviceManager.h, the DeckLinkNotificationManager constructor:
Code: Select all
   // This is a COM interface so should only be created with CreateInstance(), and managed with AddRef() and Release()
   DeckLinkNotificationManager()
      : m_refCount(1)
   {
#ifndef _WIN32
      m_decklinkDiscovery = CreateDeckLinkDiscoveryInstance();
#else
      IDeckLinkDiscovery* discovery = nullptr;

      CoCreateInstance(CLSID_CDeckLinkDiscovery, NULL, CLSCTX_ALL, IID_IDeckLinkDiscovery, (void**)&discovery);
      m_decklinkDiscovery = discovery;
#endif
      if (!m_decklinkDiscovery)
         throw std::runtime_error("CreateDeckLinkDiscoveryInstance failed: check driver is installed");
   }

So the Win32 path should not call CreateDeckLinkDiscoveryInstance, but CoCreateInstance.

Regards
Cameron

Re: OpenCV Tutorial Source Code

PostPosted: Mon Dec 07, 2020 1:23 pm
by HEILMAO
Hi Cameron,

Thanks for your response. I have made your suggested changes and am now greeted with the following:

Code: Select all
C:\Users\...\build\Release>LiveVideoWithOpenCV.exe
Capture failed: CreateDeckLinkDiscoveryInstance failed: check driver is installed


I believe that I have the correct drivers installed based on the fact that my Decklink Quad 2 is discovered correctly on the Desktop Video Setup and Blackmagic Media Express which I installed alongside the Decklink SDK 11.7.

Thanks again.

Re: OpenCV Tutorial Source Code

PostPosted: Mon Dec 14, 2020 12:06 am
by Cameron Nichols
Hi Oliver,

Can you check why CreateDeckLinkDiscoveryInstance is called by your code, this code path should only be valid for Mac and Linux builds. On Windows, the preprocessed path should call CoCreateInstance.

Regards
Cameron

Re: OpenCV Tutorial Source Code

PostPosted: Thu Nov 23, 2023 9:46 am
by bjarque
Hi,
Reviving an old post here, but I am trying to get this to work with an 8k Pro, and getting the same errors as HEILMAO.

Cameron, CoCreateInstance is called as it should, its just the error message saying "CreateDeckLinkDiscoveryInstance " from this line
Code: Select all
 throw std::runtime_error("CreateDeckLinkDiscoveryInstance failed: check driver is installed");


I tried to debug it on Windows, and CoCreateInstance doesnt seem to return a decklink instance to &discovery. That is why the exception above is thrown.
Any input to next steps to get this to work?

Thanks in advance!