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

CV.imread( ) does not get Mat #150

Closed
cike111 opened this issue Jul 9, 2024 · 7 comments
Closed

CV.imread( ) does not get Mat #150

cike111 opened this issue Jul 9, 2024 · 7 comments
Labels
question Further information is requested

Comments

@cike111
Copy link

cike111 commented Jul 9, 2024

How to load an image under the assets path to generate mat ,if using CV.imread("assets/ material_wood.jpg ") does not get the correct Mat

@cike111 cike111 added the question Further information is requested label Jul 9, 2024
@abdelaziz-mahdy
Copy link
Contributor

I think assets are not easy to handle specially on mobile

I recommend copying the file to tmp dir and use the new path

@rainyl
Copy link
Owner

rainyl commented Jul 12, 2024

I think assets are not easy to handle specially on mobile

I recommend copying the file to tmp dir and use the new path

yes,it works. a more elegant way is reading assets to bytes and use imdecode.

but for APIs without the support of loading from bytes it will be the only solution for now.

@abdelaziz-mahdy
Copy link
Contributor

And I don't think including the asset reader will work with native assets since the asset reader is from flutter

So people should manage that in their own app, maybe we can add an example?

@rainyl
Copy link
Owner

rainyl commented Jul 12, 2024

And I don't think including the asset reader will work with native assets since the asset reader is from flutter

agree, it's out of the scope of this package. maybe we can develop another package to extend this package and provide some helper functions but not for now, this package is still in heavy development and APIs are not stable enough.

So people should manage that in their own app, maybe we can add an example?

actually the example under this repo has shown how to load image from assets, but we can make another one to show this clearer and add more solutions, e.g., copy to tmp folder and load models.

@abdelaziz-mahdy
Copy link
Contributor

Ok let's open an issue with it I may check when I have time, no promises since I have been busy for a while now

@rainyl
Copy link
Owner

rainyl commented Jul 13, 2024

Ok let's open an issue with it I may check when I have time, no promises since I have been busy for a while now

Sounds good, just do it when you are free.

@rainyl
Copy link
Owner

rainyl commented Jul 14, 2024

Refer rainyl/awesome-opencv_dart#1 for further development.

As for the answer of this issue, please take a look at the example of this repo.

final data = await DefaultAssetBundle.of(context).load("images/lenna.png");
final bytes = data.buffer.asUint8List();
// heavy computation
// final (gray, blur) = await heavyTask(bytes);
// setState(() {
// images = [bytes, gray, blur];
// });
final (gray, blur) = await heavyTaskAsync(cv.imdecode(bytes, cv.IMREAD_COLOR));
setState(() {
images = [bytes, cv.imencode(".png", gray), cv.imencode(".png", blur)];

@rainyl rainyl closed this as completed Jul 14, 2024
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

3 participants