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

MAT to and from list #164

Closed abdelaziz-mahdy closed 4 months ago

abdelaziz-mahdy commented 4 months ago

i found to list for mat object, do you think a from list should be added? it will make it easier to convert to dart and from dart objects to send objects between isolates

rainyl commented 4 months ago

Actually Mat.fromList was already supported, please check it in mat.dart, and recently i added Mat.fromVec, which also supports create Mat from a wrapped vector.

And, the current implementation of Mat.tolist is not elegant, i am considering constructing vectors from c++ in the future.

abdelaziz-mahdy commented 4 months ago

Oh looks like I missed it then, anyway I wanted to use to send data across isolates

Also, imencodeasync returns bool,unilist Why it's not the same as imencode

abdelaziz-mahdy commented 4 months ago

factory Mat.fromList(int rows, int cols, MatType type, List<num> data);

is there an option to take the output of tolist and just create a mat from it ? since i think this doesnt handle 2d arrays

rainyl commented 4 months ago

First of all, sorry for the late reply, I am kind of busy recently.

Also, imencodeasync returns bool,unilist Why it's not the same as imencode

Actually imencode should return (bool, Mat) too, same as opencv-python, but I forgot it when developing the sync APIs ...😭

image

So maybe we can fix it in the next release? Afterall, so many breaking changes will be included in the next release.

Or you think we should keep the current status and keep compatibility?

is there an option to take the output of tolist and just create a mat from it ? since i think this doesnt handle 2d arrays

Yes, Mat.fromList only accepts 1D List for now, I have reviewed #165, thanks for your contribution!

abdelaziz-mahdy commented 4 months ago

First of all, sorry for the late reply, I am kind of busy recently.

Also, imencodeasync returns bool,unilist Why it's not the same as imencode

Actually imencode should return (bool, Mat) too, same as opencv-python, but I forgot it when developing the sync APIs ...😭

image

So maybe we can fix it in the next release? Afterall, so many breaking changes will be included in the next release.

Or you think we should keep the current status and keep compatibility?

is there an option to take the output of tolist and just create a mat from it ? since i think this doesnt handle 2d arrays

Yes, Mat.fromList only accepts 1D List for now, I have reviewed #165, thanks for your contribution!

dont worry, i get busy and forget to reply too,

anyway i am confused what does the bool do is that success or failure? and i think matching to the python api will be much easier for developers so i think that breaking change is needed

rainyl commented 4 months ago

@abdelaziz-mahdy

anyway i am confused what does the bool do is that success or failure?

Yes, it is.

and i think matching to the python api will be much easier for developers so i think that breaking change is needed

Ok, thanks for your advice, then I am going to change it in the next release.

sysmesh commented 2 months ago

Hope i'm not hi-jacking the thread but I am trying to use the Mat.fromVec function and it causes the app to crash (on both iOS simulator and physical iphone device). Can you please explain what is the difference between a Vector and a Wrapped Vector?

The following line: penCV.Mat docCntMat = openCV.Mat.fromVec(docCnt!);

Casues the crash. docCnt is Mat.Vec type.

Any idea/advice?

Thanks!

rainyl commented 2 months ago

Hope i'm not hi-jacking the thread but I am trying to use the Mat.fromVec function and it causes the app to crash (on both iOS simulator and physical iphone device). Can you please explain what is the difference between a Vector and a Wrapped Vector?

The following line: penCV.Mat docCntMat = openCV.Mat.fromVec(docCnt!);

Casues the crash. docCnt is Mat.Vec type.

Any idea/advice?

Thanks!

Attach your error logs please, also, better to provide a minimum reproducable example.

abdelaziz-mahdy commented 2 months ago

Also I think a new issue will be better for tracking the status