SOLVED: Opencv sfm module

I have compiled the OpenCV 4.8.0 SFM module and copied it to the site-packages/cv2 directory of TD, as well as copying the opencv_sfm480.dll file to the bin directory of TD. While I am able to print out the cv.sfm module, I am unable to access its internal functions. Could you please advise me on how I can properly integrate this module into TD?

Adding this module is going to be a challenge.

TouchDesigner comes bundled with its own version of OpenCV which is tightly integrated in multiple parts of the software.

Adding this module, when a version of OpenCV that doesn’t match or is built differently and is already loaded is likely not going to play well.

On top of this, this is really not the suggested way to add third party packages to TouchDesigner.

We have an extended documentation listing solutions: Python - Derivative

Just pointing out the following from our documentation:

:bulb:Note: When adding your own version for a package that is already shipped with TouchDesigner, you might encounter unexpected behaviors. Many of our internal tools and palette components rely on NumPy and/or OpenCV. :warning: Loading different versions of Numpy and/or OpenCV is at your own risk. Some other issue could be with the following: considering a Package A with a dependency B, if updating your sys.path cause a different version of dependency B to load first, it could cause issues with Package A.

I’d go with the Anaconda approach to keep things independent and easily testable outside of the TouchDesigner context: Anaconda - Managing Python Environments and 3rd-Party Libraries in TouchDesigner | Derivative

I’ll add a task to see with the dev team if we can add the SFM module of OpenCV to our installation by default.


1 Like