Add ML module
Question
i know that ML module is not supported yet, any way i could help with that since i want to use CascadeClassifier i think its in the ml module (i didnt check )
if i cant help with it, any time plan for it?
@abdelaziz-mahdy
If you just need CascadeClassifier, it is included in objdetect module, and has been implemented, https://docs.opencv.org/4.x/d1/de5/classcv_1_1CascadeClassifier.html
https://github.com/rainyl/opencv_dart/blob/4af53eabbd7cd077b4f27d77de7b109186b78ec7/lib/src/objdetect/objdetect.dart#L15
https://github.com/rainyl/opencv_dart/blob/4af53eabbd7cd077b4f27d77de7b109186b78ec7/test/objdetect_test.dart#L6
It seems training machine learning models using python and other tools is a more common and fashion way nowadays, and I have no much free time, so ML module was not implemented and not planned recently, maybe it will be added several months later when I have some time.
Anyway, it is true that some people need ML module, I(and other users) will be grateful if you can implement it.
Thank you very much for the links and the awesome package, I will check what needs to be implemented and try to do it
:smile:
i am trying to make some guide lines so that i follow if its okay
-
Branch Selection:
- Should I work on the main branch or the native assets branch? since The native assets branch has many changes.
-
Workflow with ffigen:
- Add the desired implementation in the
.hfiles. - Implement the logic in the
.cppfiles. - Add the interface in Dart.
- Create the test cases for the Dart interface.
- Add the desired implementation in the
-
Checklist:
- [ ] Determine the correct branch to work on.
main - [ ] Add desired implementation in
.hfiles. - [ ] Implement logic in
.cppfiles. - [ ] Run ffigen to generate bindings
- [ ] Add interface in Dart.
- [ ] Create test cases for the Dart interface.
- [ ] Determine the correct branch to work on.
Questions:
- OpenCV on iOS:
- Have you tried using OpenCV on a clean project in iOS?
- I remember having an issue with iOS and FFI where the C++ files get ignored, and the developer has to import them manually. I will check if this is still a problem. The native assets should fix this issue.
note: this is my package where i had the problem https://github.com/abdelaziz-mahdy/pytorch_lite/blob/latest-ffi/ios/pytorch_lite.podspec but i see that you created .framework which should not have this problem so ignore this question,
wow, you are the author of pytorch_lite, cool 👍
For the questions:
- Branch Selection: develop on a new branch based on
main, it is easy to updatenative-assetsonce finished onmain. - OpenCV on iOS: as you said, for ios the .framework is used, I have no apple devices so not tested, but other developers tested and it worked.
I have edited your checklist, hope you won't mind it.
BTW, you can find more build instructions in workflow file, thanks for your efforts in advance.
One more thing, to speedup the build of opencv_dart, opencv itself is built in another repo with ML disabled, I have enabled it but the workflow has not finished yet, generally it will take about 40 min, once finished, the published tag will be 4.9.0+3 so you need to change the opencv version in conanfile.py to "4.9.0+3" at https://github.com/rainyl/opencv_dart/blob/4af53eabbd7cd077b4f27d77de7b109186b78ec7/conanfile.py#L10
Oh thank you for that, is there is a guide you follow of what the headers are and the implementation for the functions? I checked gocv but looks like there is no ml module or I can't find it,
If there is something I can take a reference that will make it much easier
edit: also i see that the build finished but the release doesnt have the files https://github.com/rainyl/opencv.full/releases/tag/4.9.0%2B3
Yes, this project was originally developed based on gocv, but now nearly every API has been refactored to cache exceptions, the most important guide is the documentation of opencv, i.e., wrap the classes and functions with C-style functions.
You can take a look at cv.Subdiv2D in this PR: #60
headers: https://github.com/rainyl/opencv_dart/blob/d4690613c53c88149b110cd127e0331eb512d019/src/imgproc/imgproc.h#L168-L187
implementation: https://github.com/rainyl/opencv_dart/blob/d4690613c53c88149b110cd127e0331eb512d019/src/imgproc/imgproc.cpp#L751-L888
Edit: Now published
Yes, this project was originally developed based on gocv, but now nearly every API has been refactored to cache exceptions, the most important guide is the documentation of opencv, i.e., wrap the classes and functions with C-style functions.
You can take a look at cv.Subdiv2D in this PR: #60
headers:
https://github.com/rainyl/opencv_dart/blob/d4690613c53c88149b110cd127e0331eb512d019/src/imgproc/imgproc.h#L168-L187
implementation:
https://github.com/rainyl/opencv_dart/blob/d4690613c53c88149b110cd127e0331eb512d019/src/imgproc/imgproc.cpp#L751-L888
nice i like how clean this is done, i will check what i can do tomorrow and open a pr if i was able to implement it.
thank again for your help, this info will hopefully make it much easier for me to make the pr <3
ffigen fails in files not related to the file i made
is that a problem from my side?
running conan build . -b missing compiled successfully
adding
#include <stddef.h> before core file made it work, dont know if that the correct fix
Well, I developed on windows and it worked normally, maybe macos needs stddef.h, feel free to add it.
I have published a new branch ml with some data structures wrapped, but they were not tested, just for some detailed instructions and methods to provide some help, but forgive me that I have no more time to finish it, take a look and hoping it can help you~
Nice, thank you it helps, also now I know that you would prefer if each class has separate files, since I was implementing them in one file
And the cmake change, I forgot that part
Anyway I will try to implement it and let's see if I achieve something good ❤️