opencv_dart icon indicating copy to clipboard operation
opencv_dart copied to clipboard

Support local build, support ffmpeg for windows, linux, macos, android

Open rainyl opened this issue 1 year ago • 4 comments

  • local build, download opencv sdk from opencv.full
  • support ffmpeg for windows, linux, android, macos (ios can't embed dylib, which will conflict with LGPL 2.0 license)
  • add DartCvMacOS dependency for macos
  • add DartCvIOS for ios
  • move all dart code to independent plugin dartcv
  • move all C wrappers code to dartcv https://github.com/rainyl/dartcv
  • macos: support 10.15 and above
  • android: API level 24 and above
  • ios: 12.0 and above

rainyl avatar Oct 10 '24 16:10 rainyl

may i ask why the separation needed? like will we need android and windows and linux libs too?

same as done in media_kit?

are you planning to have configuration with ffmpeg and without it? will that help with the vulkan stuff?

abdelaziz-mahdy avatar Oct 10 '24 18:10 abdelaziz-mahdy

may i ask why the separation needed? like will we need android and windows and linux libs too?

same as done in media_kit?

  1. like i said before, i want to support ffmpeg for all platforms, better with same version.
  2. the previous building of opencv.full relies on system-wide ffmpeg, especially on macos, brew updates ffmpeg actively, so opencv.full has to be recompiled every time they update ffmpeg.
  3. thus, i want to compile opencv with custom linked ffmpeg, for this, i collected/forked some repos, including https://github.com/rainyl/FFmpeg-Builds and https://github.com/wang-bin/avbuild
  4. and, considering the increased app size and the fact that many users doesnt need it, it's better to provide a package without ffmpeg, so opencv_core was born.
  5. considering that the only difference between opencv_dart and opencv_core is the ffmpeg, both for dart and c codes, extracting the dart code and C code seems to be a good choice, right?
  6. so the dart codes were extracted to dartcv, this also benefits those who work without flutter, i.e., pure dart users, since the dependency of flutter is totally removed.
  7. As for C code, it's not necessary to extract them to an independent repo, BUT, CocoaPods requires it, so I have to, oh, and the CocoaPods, I didn't find any elegant way to integrate CMake inside podspec, like detecting the target platform and archtecture dynamically and tell CMake what to do, so I spent much time on developing two packages (DartCvIOS and DartCvMacOS) and published them to CocoaPods, in this way, we can just add s.dependency DartCvIOS to ios/opencv_dart.podspec to introduce the package and let flutter to do the rest things, e.g., produce the correct Info.plist.

To summarize, we do not need platform specific packages like media_kit, but 2 new packages for different users.

are you planning to have configuration with ffmpeg and without it? will that help with the vulkan stuff?

  • For those who need videoio, use opencv_dart
  • For pure dart users, use dartcv
  • For others, use opencv_core
  • Cons. For those who want to use platform specific backends ONLY, i.e., MSMF on windows, AVFoundation on macos and ios, MediaNDK on android, it's impossible for now, they have to compile opencv by themselves.

I am not sure about the vulkan, but I think it's no difference than before.

rainyl avatar Oct 11 '24 01:10 rainyl

Ok thank you for the explanation

Were the specific backends supported before?

abdelaziz-mahdy avatar Oct 11 '24 02:10 abdelaziz-mahdy

Were the specific backends supported before?

Yes, but they are very limited, there are several issues about this.

  • #159
  • #213
  • #245

rainyl avatar Oct 11 '24 02:10 rainyl

After seeing the issues, I think your approach is the right approach

Since ffmpeg is heavy and not needed for most cases, let me know If you need any assistance in anything

abdelaziz-mahdy avatar Oct 21 '24 12:10 abdelaziz-mahdy

After seeing the issues, I think your approach is the right approach

Since ffmpeg is heavy and not needed for most cases, let me know If you need any assistance in anything

Thanks! ffmpeg related works have almost been finished, but I am still working on universal APIs, i.e., merge sync and async C wrappers, for better maintainability and uniform dart APIs, by adding empty callbacks to the wrappers needed to be called asynchronously.

  • https://github.com/rainyl/dartcv/issues/2

this is almost finished too, however, some tests were failed and needs to be fixed. it would be helpful if you can help to fix them.

rainyl avatar Oct 22 '24 02:10 rainyl

i will look into it, is there is any new steps to running the tests locally?

abdelaziz-mahdy avatar Oct 22 '24 02:10 abdelaziz-mahdy

i will look into it, is there is any new steps to running the tests locally?

for macos, a manually built library is needed, I will add another action to build it in https://github.com/rainyl/dartcv

rainyl avatar Oct 22 '24 07:10 rainyl

All tests passed now.

@abdelaziz-mahdy You can download prebuilt libs from https://github.com/rainyl/dartcv/releases/tag/4.10.0%2B2 now.

rainyl avatar Oct 23 '24 04:10 rainyl