OpenCV Camera Calibration

Hey TD folks,

I’ve built a first version of a C++ DAT for camera calibration with a checkerboard pattern based on OpenCV:
github.com/guidoschmidt/Touchdesigner.Camera-Calibration

I built it mainly because I wanted to digg into C++ development with Touchdesigner and needed to undistort a GoPro camera that I’m using through a Blackmagic capture card. You take a couple of images with a checkerboard and use a Folder DAT to get the list of images to the calibration process. After the calibration it undistorts an input TOP accordingly. There’s still some stuff I wanted to improve but I’m quite happy with this first version :slightly_smiling_face:

Does anyone has experience using threads from C++ plugins within Touchdesigner? It would be nice if the calibration process could run async and not block the TD main thread. I’ve tried to achive this with std::async but still TD is blocking when the calibration is running, could be due to shared data/objects within the CPlusPlusDAT :thinking:

Cheers from Germany
Guido

3 Likes

Hi Guido,
Thanks for the new asset! We are trying to get all assets uploaded now to the COMMUNITY ASSETS section of the website, as this category was imported from the old forum but going forward we’d like all assets in that one place. Any chance you can upload it there? Just go to MY ACCOUNT and click ‘Create Asset Post’.

Perhaps this category should be locked for new topics to encourage this, sorry for the confusion.

1 Like

Hey ben,

ah I’ve seen that already but wasn’t sure if I should put my post up there, thanks for the clarification! :v:

1 Like

Thanks for posting this, great to see more and more Custom OPs being created!
One note about the GPL, you need to modify the license otherwise people aren’t allowed to use your code with TouchDesigner:
https://www.gnu.org/licenses/gpl-faq.html#GPLPluginsInNF

1 Like

Ah thanks for pointing that out, I’ve changed the license to MIT :call_me_hand:

Hey guido,

Couldn’t tried out your DAT implementation. Built dll with VS 16 but it gives an error. Can you provide your Visual Studio version and OpenCV dlls in use? I am using TD version 2019.19160.

Also, check Markus’s example right here. Flawless work.

Hey Guido!

long time no see :smiley: The DLL compiles fine with VS2019 and OpenCV 4.3. After renaming the op it runs under TD 2020.23680. Great work! Working with the Op is much nicer than handling with python scripts. I was about to code my own version…but then found this one. This is how I ended up here :smiley:

I forked your master branch. When there is time I would like to add some stuff (options _performCalibrationFlags, …). Thank again for your great contribution!

1 Like

Haha nice coincidence! Great to see you here.

In fact the camera calibration was hacked together in January to try out C++ in touchdesigner and to implement a proof-of-concept, I didn’t touch it since then. Feel free to add functionality, would be well appreciated. I still wanted to check out threading to make the code not block the whole application :thinking: Also having the possibilty to serialize and load lens calibration files would be nice.