Levi-Lesches / opencv_ffi

An FFI-based implementation of OpenCV in Dart
https://pub.dev/packages/opencv_ffi
Other
18 stars 1 forks source link

[Feature Request] More/Full OpenCV API #22

Closed rainyl closed 9 months ago

rainyl commented 10 months ago

It is so great that you and your gourp managed to create opencv bindings for dart, actualy as a newbee to dart and flutter, I am so infrastrating that there is NO complete opencv bindings for dart!!! Opencv is the fundamental of computer vision, and the bindings for other language are complete like python and C#.

However, I have also noticed that the API in your work is really not sufficient, I understand that maybe this project is just for your group's work, but it will be nice to add more API, to become the first usable and complete opencv bindings for dart.

Further more, I have made a little efforts on it, and find the the pure-C API for opencv, i.e., OpenCV-C project, https://github.com/friolator/OpenCV-C , I am sure it will be useful to your works, with ffigen it will be easier to create bindings, and maybe with the development of dart's Native Assets feature, the situation will be better.

Finally, really appreciate and thankful to your works, waiting for this project‘s development!

Levi-Lesches commented 10 months ago

Nice find! When I last researched it, I found the official OpenCV C API. Despite being deprecated, I thought I'd give it a go anyway... but not only did they deprecate it, they also replaced all the source to print a deprecation message and return nullptr. Crazy stuff, so I gave up and wrote some C headers manually and tried to make a Dart-friendly API around it. As you can see, that pretty much limits how far we got, mostly because of how much time it takes.

I definitely intend for this package to be the OpenCV implementation in Dart though, so I will take a look at your link and re-assess. I've contacted the repo owner for details -- such as how far behind the latest OpenCV they are -- and if I get good answers I can look into how this can be done efficiently and hopefully with lots of automation. Any help from you or anyone reading this issue would be much appreciated, as I am quite busy this time of year

rainyl commented 10 months ago

I have managed to compile opencv-c with latest stable opencv 4.9.0 and for now it worked well, BUT, there do have some API not finished, like cv::findContours(), it seems that all functions with cv::OutputArrayOfArrays were commented and not finished, https://github.com/friolator/OpenCV-C/blob/e5cbad86c0daa9f32f9602398dd216c81db348cf/Source/CVCImgProc.h#L1029

blueming333 commented 9 months ago

"Keep it up, this feature is very useful. hope there will be more APIs related to images."

Levi-Lesches commented 9 months ago

@rainyl The author of opencv-c has not responded to me yet. Do you think this is worth pursuing, in its current state?

rainyl commented 9 months ago

Personally, now I think opencv-c is not the best choice, neither it's coverage of opencv APIs nor it's API style is good enough.

Currently, I think the C wrappers from gocv may be more proper to use, and based on gocv, I have started to write opencv bindings for dart, see more details here: https://github.com/rainyl/opencv_dart , but it's still a long way to go, many many tests are not complete and need to debug, welcome to contribute! BTW, since you said you may have not enough time to do it, I didn't open PRs to this repo, but if you are interest to do it, contributions are welcome and maybe we can merge the two repos.

Levi-Lesches commented 9 months ago

Personally, now I think opencv-c is not the best choice, neither it's coverage of opencv APIs nor it's API style is good enough.

Agreed, putting a pin on that.

Currently, I think the C wrappers from gocv may be more proper to use, and based on gocv, I have started to write opencv bindings for dart, see more details here: https://github.com/rainyl/opencv_dart , but it's still a long way to go, many many tests are not complete and need to debug, welcome to contribute!

Nice! I didn't come across gocv in my research, but it seems a lot of effort is being put into that to keep it up-to-date, and so I think that's a good idea to adopt.

BTW, since you said you may have not enough time to do it, I didn't open PRs to this repo, but if you are interest to do it, contributions are welcome and maybe we can merge the two repos.

Sorry for the confusion then -- if it's okay with you I'd love to contribute and merge our repos (definitely not biased, but I kinda think _ffi is a clear name and is explicit about how it works, why the long build time, and it doesn't support web, and _dart may imply it's a Dart-only rewrite, like package:firebase_dart). I want to completely redo the structure of this repo anyway, to include all the OpenCV APIs, so if you want to make a new branch, set it up the way you want to/have it on your side, I'd merge that and help you build on it. Obviously, if we do this, I'd be happy to list you on the README as a major contributor. Then we can add features like #27 and #20, as well as some of the other image processing functions I've been using internally.

Just curious, what's the difference between your fork of gocv and the real deal? And do you plan to merge your changes upstream or keep merging whenever the original gocv pushes changes?

rainyl commented 9 months ago

Sorry for the confusion then -- if it's okay with you I'd love to contribute and merge our repos (definitely not biased, but I kinda think _ffi is a clear name and is explicit about how it works, why the long build time, and it doesn't support web, and _dart may imply it's a Dart-only rewrite, like package:firebase_dart).

After searching on pub.dev, I found the opencv releated package names were messy and good names were already registered, so dart suffix was used. _ffi is intuitive but if web support is planed it won't be the best choice, and when searching on pub.dev, the supported platforms are already annotated, so unless we can get the ownership of name opencv, it is not important about the package name itself.

I want to completely redo the structure of this repo anyway, to include all the OpenCV APIs, so if you want to make a new branch, set it up the way you want to/have it on your side, I'd merge that and help you build on it. Obviously, if we do this, I'd be happy to list you on the README as a major contributor. Then we can add features like https://github.com/Levi-Lesches/opencv_ffi/issues/27 and https://github.com/Levi-Lesches/opencv_ffi/issues/20, as well as some of the other image processing functions I've been using internally.

Based on the above comsideration and looking into this repo, it seems only camera related APIs are implemented, but I have implemented most APIs including the above two issues you mentioned, so why not just write more tests and debug in mine? However, I am happy to register an organization to do this, if you and your team are interest in it, afterall the ecosystem of opencv for dart is very fragmented, efforts should be concentrated to develop a complete one.

Just curious, what's the difference between your fork of gocv and the real deal? And do you plan to merge your changes upstream or keep merging whenever the original gocv pushes changes?

gocv's wrapper is great but not complete, so I added some extra APIs. I am not a go developer so merge to upstream is not planed, but keeping update to upstream is in consideration.