Closed KartikGavhale closed 1 month ago
@KartikGavhale Thanks for your report.
Could you please attach an example image so I can test it?
Hi @rainyl , i tried using two following code
final data = File(imagepath).readAsBytesSync();
Uint8List bytes = data.buffer.asUint8List();
colorimg = cv.imdecode(bytes,cv.IMREAD_ANYCOLOR);
and colorimg=cv.imread(imagepath);
both returned the empty data in mat without error I have to for the image picker to get 50% image quality then only its giveing me the data.
attaching referance image which i used
@KartikGavhale Thanks for your response, but I cant reproduce it with the following steps:
flutter create -t app --platforms ios,android,windows,linux,macos --org dev.rainyl --project-name opencv_dart_issue258 opencv_dart_issue258
cd opencv_dart_issue258
flutter pub add image_picker opencv_dart
lib/main.dart
Pick Image
buttonI also tested it on android and it worked fine.
@rainyl can you confirm if you had picked image from gallery? Please test this with some good quality picture captured by camera and choose it from gallery. I tried multiple time .
@KartikGavhale Yes, it works in my test, even with large images (3472*4624)
However, in these cases, large images may not be freed timely due to the inherent problem of dart:ffi
, so you must manage the memories carefully, or the app may reach the maximum memory limitation and be killed by OS (you can inspect this via DevTools).
Related issues about dart objects and native objects:
e.g., in the above example, change the function heavyTaskAsync
to:
Future<(cv.Mat, cv.Mat)> heavyTaskAsync(cv.Mat im, {int count = 1000}) async {
late cv.Mat gray, blur;
for (var i = 0; i < count; i++) {
gray = await cv.cvtColorAsync(im, cv.COLOR_BGR2GRAY);
blur = await cv.gaussianBlurAsync(im, (7, 7), 2, sigmaY: 2);
if (i != count - 1) {
gray.dispose(); // manually dispose
blur.dispose(); // manually dispose
}
}
return (gray, blur);
}
@rainyl , ok will try to get if i found any certain error. Thanks for the continues support buddy.
Describe the bug im trying to pick image from mobile galary , i used imdecodeasync to decode a 16MP resolution image , when i checked the returmed mat.data , its giveing me null
To Reproduce 1.using image picker to pick image from galary .