Skip to content

The cv. imread (path) method reports an error on iOS devices #144

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

Closed
Jiabaokang opened this issue Jul 4, 2024 · 5 comments
Closed

The cv. imread (path) method reports an error on iOS devices #144

Jiabaokang opened this issue Jul 4, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@Jiabaokang
Copy link

Describe the bug
Used in Flutter projects opencv dart: ^1.0.10
The Android project is working fine, but the following exception occurs on the iOS device. Both the real device and the emulator get the same error message

Error log
[core] "Error returned from daemon: Error Domain=com.apple.accounts Code=7 "(null)"" [PAAccessLogger] Failed to log access with error: access=<PATCCAccess 0x2807378d0> accessor:<<PAApplication 0x282b777f0 identifierType:auditToken identifier:{pid:912, version:2646}>> identifier:E8F03A6E-7078-4BE7-AA51-51EFD85FE758 kind:intervalEnd timestampAdjustment:0 tccService:kTCCServicePhotos, error=Error Domain=PAErrorDomain Code=10 "Possibly incomplete access interval automatically ended by daemon" [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to lookup symbol 'Image_IMRead': dlsym(RTLD_DEFAULT, Image_IMRead): symbol not found #0 DynamicLibrary.lookup (dart:ffi-patch/ffi_dynamic_library_patch.dart:33:70) #1 CvNative._Image_IMReadPtr (package:opencv_dart/src/opencv.g.dart:5974:34) #2 CvNative._Image_IMReadPtr (package:opencv_dart/src/opencv.g.dart) #3 CvNative._Image_IMRead (package:opencv_dart/src/opencv.g.dart:5975:30) #4 CvNative._Image_IMRead (package:opencv_dart/src/opencv.g.dart) #5 CvNative.Image_IMRead (package:opencv_dart/src/opencv.g.dart:5964:12) #6 imread.<anonymous closure>.<anonymous closure> (package:opencv_dart/src/imgcodecs/imgcodecs.dart:26:22) #7 cvRun (package:opencv_dart/src/core/base.dart:66:17) #8 imread.<anonymous closure> (package:opencv_dart/src/imgcodecs/imgcodecs.dart:26:5) #9 cvRunArena (package:opencv_dart/src/core/base.dart:84:31) #10 imread (package:opencv_dart/src/imgcodecs/imgcodecs.dart:24:10) #11 ImageDetection.detection (package:ai_detection/image_detection.dart:45:21) #12 _MyHomePageState._selectPicture (package:ai_detection/main.dart:61:20) <asynchronous suspension>

Code error location
final imagePicker = ImagePicker(); final result = await imagePicker.pickImage(source: ImageSource.gallery,); String imagePath = result?.path; if(imagePath != null){ cv.Mat src = cv.imread(imagePath) }

Runtime environment
[✓] Flutter (Channel stable, 3.22.0, on macOS 14.5 23F79 darwin-x64, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] IntelliJ IDEA Community Edition (version 2023.2.4)
[✓] VS Code (version 1.90.2)
[✓] Connected device (3 available)
[✓] Network resources

Flutter version:
-Flutter 3.22.0 • channel stable • https://github.com/flutter/flutter.git
-Framework • revision 5dcb86f68f (8 weeks ago) • 2024-05-09 07:39:20 -0500
-Engine • revision f6344b75dc
-Tools • Dart 3.4.0 • DevTools 2.34.3

There is currently no solution to this problem. If there is a good solution, please share it. Thank you very much

@Jiabaokang Jiabaokang added the bug Something isn't working label Jul 4, 2024
@Jiabaokang
Copy link
Author

Additional information
iOS-Real machine version:15.8.2
iOS-Simulator version:17.0
image

@rainyl
Copy link
Owner

rainyl commented Jul 4, 2024

It seems the dynamic lib was not loaded correctly, could you please take a look at ~/.pub-cache/hosted/pub.dev/opencv_dart-1.0.10/ios and see whether the opencv_dart.xcframework exists and not empty? you can also manually run setup command and try again.

It should looks like

image

@Jiabaokang
Copy link
Author

Project in the pub-cache/hosted/pub.dev/opencv_dart-1.0.10/ios directory, but there is no this file opencv_dart.xcframework, What command do you need to run to generate theopencv_dart.xcframeworkfolder?

@rainyl
Copy link
Owner

rainyl commented Jul 4, 2024

It will be downloaded and extracted from github releases during flutter build, check whether the .tar.gz file exists and correct.

If your network is unstable, it may not be downloaded successfully, the you can either run setup commands manually (read README carefully) or download .tar.gz manually and move it to the ios directory in pubcache (refer to the structure I posted above), then it will be extracted automatically during flutter build/run.

Note: you need to ensure that wget and tar are installed.

@Jiabaokang
Copy link
Author

According to your method, the dynamic link library has been successfully loaded and the issue has been fixed. Thank you for your answer. I am not sure if it is an issue with my local development environment, as there are other dynamic libraries loaded in the project, and it seems that the same error did not occur. Thank you for your answer. You can close this bug now.

感谢指导

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants