Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to load dynamic library 'opencv_dart.dll' #255

Closed
BluesCool opened this issue Sep 30, 2024 · 10 comments
Closed

Failed to load dynamic library 'opencv_dart.dll' #255

BluesCool opened this issue Sep 30, 2024 · 10 comments
Labels
question Further information is requested

Comments

@BluesCool
Copy link

According to your prompts, I went to ~\AppData\Local\Pub\Cache\hosted\pub.dev\opencv_dart-\windows to find the dll file, but I did not find it.
I may have switched the downloaded warehouse due to network reasons. My directory can be found in the directory \AppData\Local\Pub\Cache\hosted\pub.flutter-io.cn\opencv_dart-1.2.5\windows.
What do I need to do?

@BluesCool BluesCool added the question Further information is requested label Sep 30, 2024
@rainyl
Copy link
Owner

rainyl commented Sep 30, 2024

@BluesCool Hello.

If it's difficult to resolve your network conditions to make dart run opencv_dart:setup work, you can
downlaod .tar.gz from https://github.com/rainyl/opencv_dart/releases/tag/v1.2.5 and extract, then move opencv_dart.dll to \AppData\Local\Pub\Cache\hosted\pub.flutter-io.cn\opencv_dart-1.2.5\windows

@BluesCool
Copy link
Author

@rainyl Hello.
\AppData\Local\Pub\Cache\hosted\pub.flutter-io.cn\opencv_dart-1.2.5\windows, I can find opencv_dart.dll,
When I run the example you provided, it prompts ArgumentError (Invalid argument(s): Failed to load dynamic library 'opencv_dart.dll': Invalid access to memory location.
(error code: 998))

@rainyl
Copy link
Owner

rainyl commented Sep 30, 2024

I just tested on my Windows 11 PC but can't reprocude it.

Provide more informations please, e.g., the structure of pub.flutter-io.cn\opencv_dart-1.2.5\windows and the steps to reproduce.

@BluesCool
Copy link
Author

I just added this dependency in pub.yaml,
and then used the code you provided:
final img = cv.imread("test/images/lenna.png", flags: cv.IMREAD_COLOR);
final gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY);
print("${img.rows}, ${img.cols}");
cv.imwrite("test_cvtcolor.png", gray);

In cv.imread("test/images/lenna.png", flags: cv.IMREAD_COLOR); reported an error, as follows: [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to load dynamic library 'opencv_dart.dll': Invalid access to memory location. (error code: 998) #0 _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:11:43) #1 new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:22:12) #2 loadNativeLibrary (package:opencv_dart/src/native_lib.dart:37:29) #3 cimgcodecs (package:opencv_dart/src/native_lib.dart:47:48) #4 cimgcodecs (package:opencv_dart/src/native_lib.dart) #5 imread. v_dart/src/core/base.dart:83:76) #7 imread. (package:opencv_dart/src/imgcodecs/imgcodecs.dart:29:5) #8 cvRunArena (package:opencv_dart/src/core/base.dart:234:31) #9 imread (package:opencv_dart/src/imgcodecs/imgcodecs.dart:27:10)
#10 OpencvService.test (package:fat/services/opencv_service.dart:13:20)

Then, as mentioned above, I went to find 'opencv_dart.dll'. The folder that differs from your prompt is pub.flutter-io.cn. Yours is named pub.dev.

@rainyl
Copy link
Owner

rainyl commented Sep 30, 2024

  1. Check the hash value of opencv_dart.dll via Get-FileHash -Algorithm sha256 .\opencv_dart.dll, it should be 1EC16101DCB0A8F79A97E67826385F7BA9BCA9FCBD1E582FE4859174852B6CE6
  2. Provide the info of your hardware and OS, i.e., windows 10 or windows 11, x86, x64 or arm64, for windows, this plugin was only tested on windows 11 x64 (should work on windows 10 x64 too)
  3. The version of Flutter/dart? also attach the output of flutter doctor

@BluesCool
Copy link
Author

1.‘ED67F391C1B1DD8E12BD2A01152ABE77010AB3DF2F499AFD0DBAE274517CA6BA’ My output is different from yours
2.My operating system is windows11 x64.
3.The flutter doctor information is as follows:
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.22.0, on Microsoft Windows [版本 10.0.22631.4169], locale zh-CN)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
X Could not determine java version
X Android license status unknown.
Run flutter doctor --android-licenses to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Professional 2022 17.9.6)
[!] Android Studio (version 2021.3)
X Unable to find bundled Java version.
[√] IntelliJ IDEA Ultimate Edition (version 2022.3)
[√] Connected device (3 available)
[√] Network resources

@rainyl
Copy link
Owner

rainyl commented Oct 7, 2024

@BluesCool

1.‘ED67F391C1B1DD8E12BD2A01152ABE77010AB3DF2F499AFD0DBAE274517CA6BA’ My output is different from yours

Apparently, your opencv_dart.dll was broken, please download from https://github.com/rainyl/opencv_dart/releases/download/v1.2.5/libopencv_dart-windows-x64.tar.gz and try again.

@BluesCool
Copy link
Author

I downloaded and replaced it, but the effect is still the same. I tested the hash value and it is consistent with what you gave.
Is there any other operation?

@BluesCool
Copy link
Author

I changed the computer and this problem did not occur.

@rainyl
Copy link
Owner

rainyl commented Oct 8, 2024

I changed the computer and this problem did not occur.

Well, maybe something was broken in your previous PC...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants