Aladeen
Aladeen

Reputation: 58

How to use opencv (c++) code in blender?

I am working on hand gesture recognition using computer vision for motion simulation. I do not have as good knowledge of python as i have of c++ and hence have programmed an opencv code in c++. Now i want this code to work in a blender. Please tell me how can i integrate this code in blender.

Upvotes: 2

Views: 1082

Answers (1)

sambler
sambler

Reputation: 7079

Without altering blender's source code and compiling your own custom version, you will need to use an addon to use your code within blender. Blender uses python for it's addon system, each addon is a python module. You can use python's ctypes module to call compiled code from a python script.

While normally an addon is written in python it is possible to use or integrate a compiled C/C++ python module that can be used in blender. I'm not 100% sure if you can compile the module and add it to blender's addon folder or whether you need to have a folder with the library and a small python script that loads it.

You may want to look at cython, it takes python code and turns it into C/C++ code that can be compiled, this may give you a starting point to linking with your code. Have a look at CubeSurfer for an example of using cython for a blender addon.

For blender specific help you will find blender.stackexchange.com better.

Upvotes: 4

Related Questions