rainyl / opencv_dart

OpenCV bindings for Dart language and Flutter. Support Asynchronous Now!
https://pub.dev/packages/opencv_dart
Apache License 2.0
138 stars 18 forks source link

vulkan missing dynamic libs? #188

Closed abdelaziz-mahdy closed 3 months ago

abdelaziz-mahdy commented 4 months ago

Read README carefully first Star :star: this project if you want to ask a question, no star, no answer

Question

we enabled vulkan but as you see it looks like it needs a lib to be added ?

that log will only show if setLogLevel(LOG_LEVEL_ERROR); is in the main function

for code example https://github.com/abdelaziz-mahdy/face_grouping

i found this https://docs.opencv.org/4.x/d6/dea/tutorial_env_reference.html which shows OPENCV_VULKAN_RUNTIME should be the path to lib, which is weird since in the other docs they didnt mention that, do you think we can include it to the libs served by opencv?

Could not load Vulkan library: libMoltenVK.dylib!
Please download the Vulkan SDK and set the environment variable of OPENCV_VULKAN_RUNTIME according to your system environment.
For M1 Mac and IOS, we use MoltenVK to map the Vulkan code to native apple Metal code.
You can download the SDK from https://vulkan.lunarg.com/sdk/home.
The following are some examples:
For Windows, OPENCV_VULKAN_RUNTIME=D:\VulkanSDK\1.3.236.0\Bin\vulkan-1.dll
For Linux, OPENCV_VULKAN_RUNTIME=/opt/vulkan/1.3.236.0/x86_64/libvulkan.so
For MacOS of x86, OPENCV_VULKAN_RUNTIME=/opt/vulkan/1.3.236.0/x86_64/libvulkan.dylib
For MacOS of M1 or IOS, OPENCV_VULKAN_RUNTIME=/opt/VulkanSDK/1.3.231.1/MoltenVK/dylib/macOS/libMoltenVK.dylib
[ERROR:flutter/runtime/dart_isolate.cc(1291)] Unhandled exception:
CvException(code: -2, err: , msg:OpenCV(4.10.0) /Users/runner/work/opencv.full/opencv.full/build/opencv/modules/dnn/src/vkcom/src/context.cpp:356: error: (-2:Unspecified error) loadVulkanLibrary failed in function 'Context'
) in Context of file /Users/runner/work/opencv.full/opencv.full/build/opencv/modules/dnn/src/vkcom/src/context.cpp:356
#0      throwIfFailed (package:opencv_dart/src/core/base.dart:74:5)
#1      cvRun (package:opencv_dart/src/core/base.dart:79:58)
#2      FaceDetectorYN.detect (package:opencv_dart/src/objdetect/objdetect.dart:796:5)
#3      ImageService._detectFaces (package:face_grouping/services/image_service.dart:154:28)
#4      ImageService._processDirectoryIsolate (package:face_grouping/services/image_service.dart:124:29)
<asynchronous suspension>
abdelaziz-mahdy commented 4 months ago

checking vulkan i see that the runtime libs are huge for macos. 240 mb so i guess vulkan will not work? or you think there is another way to serve a small version

only windows runtime vulkan libs can be provided which is 13 mb

edit: this https://github.com/opencv/opencv/issues/16854 may help but we will need to check the increase in lib size hopefully it wont be alot

for compilation script vulkan is loaded so i am lost now https://github.com/rainyl/opencv.full/actions/runs/10078559285/job/27863730109#step:4:749

rainyl commented 3 months ago

On windows, at least on my PC, vulkan runtime is pre-installed. image

And for all desktop platforms, I think we do not nedd to worry about it, opencv dynamically linked it and will only load if needed, so if users need vulkan they can install it manually.

I tested on Android too and found it's also already installed. image

BTW, ios doesn's support vulkan.

So don't worry, just install it manually.

BUT, in my test, both windows and android throws an error indicating some shaders are not supported, I didn't test on macos so don't know whether it will also occur on mac.

abdelaziz-mahdy commented 3 months ago

So I guess it's a limitation from opencv! I mean they did mention that vulkan support is experimental

If I can't serve with the app, I don't think I will use it, I hate to have installation steps as a user, so I don't want to do that to users,

Thank you very much for looking into it, should we leave the issue open? Or close as not planned

rainyl commented 3 months ago

Yes, it's the limitation of opencv, not the problem of this project, so just close this issue.