rainyl / opencv_dart

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

Getting a "requested object not found in glob_rec"? Can you help? #291

Closed armaksymov closed 1 week ago

armaksymov commented 1 week ago

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

Question

Hey there,

Have been playing with your package for quite a while now and lately, I have been getting the following error when I am trying to call to any OpenCV functions: E/cv::error()( 5073): OpenCV(4.10.0) Error: Requested object was not found (could not open directory: /data/app/~~D15mpM7G9gbHvF7HkrdjMA==/com.example.vo_app-CDPBZ8s66261d7c7ytdxgQ==/base.apk!/lib/x86_64) in glob_rec, file /home/runner/work/opencv.full/opencv.full/opencv/modules/core/src/glob.cpp, line 279

I've tried upgrading to 1.3.2 (from 1.3.0) and tried downgrading to 1.2.4 and lower. Nothing seems to help :( :( :(

I would really appreciate some help here!

Thank you so much, Artem

rainyl commented 1 week ago

@armaksymov Could you please provide an minimal reproducible example?

Generally it should be the problem about permissions.

rainyl commented 1 week ago

And, if you are doing something about path, e.g., reading images or videos, make sure providing the ABSOLUTE path to opencv.

armaksymov commented 1 week ago

Hey, thank you so much for the fast follow-up! Truly appreciate this.

I have looked into this a little more, and the issue seems to be happening when I call any instance of the cvtColor method. For instance, in my code: final grayscale = cvtColor(imageData, COLOR_RGB2GRAY);, where imageData is an imdecoded rgb image. I've tried to play around and passed a BGRA and a YUV images and got the same error. I've also tried to do BGRA2RGB and RGB2BGRA switches and they all produce the same error. I am wondering what are your thoughts on this.

Thank you!

rainyl commented 1 week ago

okay, then would you mind to provide a reproducible example so I can test it?

rainyl commented 1 week ago

Allrigt, reproduced, it seems something wrong with RGB related image, will look into it.

rainyl commented 1 week ago

References:

rainyl commented 1 week ago

@armaksymov I have re-built opencv sdk and added -DPARALLEL_ENABLE_PLUGINS=OFF, delete your cache by flutter clean and delete DARTCV_CACHE_DIR/Android if you have set DARTCV_CACHE_DIR, then run it again, if it still doesn't work, tell me please.

armaksymov commented 1 week ago

Hey, thank you so much for looking into this! I will test the fix later in the day and keep you posted.

Again, thank you for looking into this so fast :)

armaksymov commented 1 week ago

Hello @rainyl, I have cleaned up what needed to be cleaned up and rebuilt the app. From my understanding, I don't have control over how opencv SDK builds, so I saw no change and was able to reproduce the same error in the same way as before. If I am wrong on not being able to influence the opencv build - could you please let me know how can I do so? If you are the one who needs to do it - it would most probably mean I would need a fresh pull of the plugin?

rainyl commented 1 week ago

TL;DR: remove the cached opencv packages.

Detailed:

it would most probably mean I would need a fresh pull of the plugin?

Yes, I forget that flutter will build native libraries in android/.cxx of package cache, so you may also need to delete the cache too, you can find it in C:\Users\<your username>\AppData\Local\Pub\Cache\hosted\pub.dev on windows and ~/.pub-cache/hosted/pub.dev on macos and linux, just delete the package starts with opencv_core or opencv_dart with the version you used.

Or, you can delete C:\Users\<your username>\AppData\Local\Pub\Cache\hosted\pub.dev\opencv_core-1.3.2\android\.cxx directory only.

image

Edit:

From my understanding, I don't have control over how opencv SDK builds, so I saw no change and was able to reproduce the same error in the same way as before. If I am wrong on not being able to influence the opencv build - could you please let me know how can I do so?

As you know, opencv is a large project, building opencv sdk is slow and unnecessary on user's computer, so the sdk will be downloaded from https://github.com/rainyl/opencv.full/releases , you do can control the building process by building opencv locally and setting the DARTCV_DISABLE_DOWNLOAD_OPENCV and OpenCV_DIR environment variables according to https://github.com/rainyl/dartcv/blob/d3335ea37d65a33170268812c875c4910440752d/cmake/download_setup_opencv.cmake#L31-L43 but it's not recommended.

Since this is the bug of opencv itself but not opencv_dart, so I didn't bump its version, just rebuilt and updated the sdk.

armaksymov commented 1 week ago

Hello @rainyl,

I have tested the application in multiple use cases that were throwing these errors and it has been working more than fine so far. I've again tested multiple conversions and none of them threw errors. I will close this and revisit if this ever comes back.

Thank you very much for your prompt help with this, this is much appreciated!

Many thanks, Artem

rainyl commented 1 week ago

Nevermind, have fun with opencv~