Open mratsim opened 3 years ago
Feel free to create a separate project. This repo is quite old now and I haven't done any OpenCV since then really.
If a wrapper must be made, I think that a better approach is to create a module in opencv_contrib like for Julia (https://github.com/opencv/opencv_contrib/tree/master/modules/julia)
I see two advantages:
After, maybe use this project or create another to download and build OpenCV with Nim binding in the good place to use it in Nim.
Also, I tried Nimterop with OpenCV without succeed. Unfortunately there hasn't been much happening on the project for some time as if the main contributor has disappeared.
I'm not touching OpenCV CMake even with a 100-foot pole. Lost too much time trying to deal with linking there.
Building OpenCV takes ages even on a beefy machine, from an ergonomics standpoint it's better to have people only require OpenCV installed (or have a downloader for a precompiled one) instead of expecting everyone to have GCC or Clang installed, a beefy machine and the time to wait on OpenCV install. And I'm not even talking about CMake, finding dependencies and linking.
I have build OpenCV a lot and it can be complex and very long.
So you propose a project that generate automatically a binding of OpenCV with a script (nimscript of course). When you use it with nimble in your personal project, you have the binding code and OpenCV's compiled libraries with its dependencies for the good platform of course. The OpenCV building can make by the CI for several platforms.
This project can be in SciNim group and propose additional features.
Futhark works great with C, but not yet with C++, but the C++ parsing is (mostly) already in place.
currently: 1- opir uses libclang to turn C header into JSON 2- futhark reads JSON and turns it into nim file with importc pragmas
But for C++ opencv2 process is halfway there:
Namespace
and CXXMethod
JSON output
opir -xc++ -I/usr/include/opencv4 opencv2/core.hpp | jq | ansi2txt > opencv2_core.json
opencv2_core.txt
stderr only
opir -xc++ -I/usr/include/opencv4 opencv2/core.hpp 2>&1 >/dev/null | ansi2txt > opencv2_stderr.txt
opencv2_stderr.txt
It seems like the C API is going the way of the dodo https://answers.opencv.org/question/185693/is-c-api-alive-or-not/
Though I would be surprised if the embedded folks don't push back or decide to maintain their own C API.
The post mentions the code generator for the C++ API in Python that can be used:
In terms of organization, we can: