node-opencv icon indicating copy to clipboard operation
node-opencv copied to clipboard

Automatically Generated Bindings

Open Queuecumber opened this issue 10 years ago • 8 comments

Something I've been looking into for a little while. The OpenCV build process generates python and matlab bindings automatically from the C++ source. One of the issues these JS bindings seem to have is lack of feature support. What do you think about cutting a new version that can do a similar automatic generation for javascript?

Of course this would be very much incompatible with the current JS api, but we would theoretically be able to support most if not all of the features and they would match the C++ api closer

Queuecumber avatar Sep 01 '15 14:09 Queuecumber

http://answers.opencv.org/question/6618/how-python-api-is-generated/ just for reference.

aaaristo avatar Oct 01 '15 12:10 aaaristo

I don't mean to populate the Issues page here. I'm currently having to wade through the Examples to find ways of doing things. Is there a list of implemented functions? Please see my question here http://stackoverflow.com/questions/34518140/list-of-node-opencv-function-names

ylh888 avatar Dec 29 '15 20:12 ylh888

Is there any reason why we couldn't generate Javascript bindings from the same tool, then augment them to add things like async calls and streaming? Has anyone tried this?

johncant avatar Feb 18 '16 18:02 johncant

Hi @Queuecumber , here's my effort so far:

https://github.com/johncant/opencv/tree/node_bindings

Essentially, all I've done so far is copied and pasted bits of cmake involved in the Python bindings generation to get to the point where the node bindings would be generated. My plan is:

  • Hack gen2.py to produce safe C++ for use with node.js
  • Produce typescript definitions
  • Also produce an async version of every function (saves having to manually annotate anything)
  • Get it to compile
  • The next step I'm a bit unsure of. Maybe an npm module is necessary for people to put in their package.json . Its only function would be to find the installed bindings and require them. Or, maybe a script to turn opencv into a standalone node module that publishes itself.

johncant avatar Feb 23 '16 13:02 johncant

There's also supposed to be a way of getting OpenCV to compile to Javascript using Emscripten but I can't find any info on it.

johncant avatar Feb 23 '16 15:02 johncant

Did you get any further with this @johncant? I like this approach.

danschultzer avatar Sep 05 '16 16:09 danschultzer

Found this library that seems to generate bindings automatically :rocket: https://github.com/ucisysarch/opencvjs

danschultzer avatar Oct 22 '16 04:10 danschultzer

Another approach would be to do it similar to the Matlab bindings. This module is very well documented in the official opencv_contrib repository.

darkdragon-001 avatar Feb 27 '17 14:02 darkdragon-001